hdu 6069 Counting Divisors(2017多校第四场)
来源:互联网 发布:linux mount cifs 编辑:程序博客网 时间:2024/06/06 02:55
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6069
Counting Divisors
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 3282 Accepted Submission(s): 1221
Problem Description
In mathematics, the function d(n) denotes the number of divisors of positive integer n .
For example,d(12)=6 because 1,2,3,4,6,12 are all 12 's divisors.
In this problem, givenl,r and k , your task is to calculate the following thing :
(∑i=lrd(ik))mod998244353
For example,
In this problem, given
Input
The first line of the input contains an integer T(1≤T≤15) , denoting the number of test cases.
In each test case, there are3 integers l,r,k(1≤l≤r≤1012,r−l≤106,1≤k≤107) .
In each test case, there are
Output
For each test case, print a single line containing an integer, denoting the answer.
Sample Input
31 5 11 10 21 100 3
Sample Output
10482302
Source
2017 Multi-University Training Contest - Team 4
Recommend
liuyiding | We have carefully selected several similar problems for you: 6143 6142 6141 6140 6139
解析:n = k1^x1*k2^x2*........kn^xn, (k1, k2, k3.......kn是质数, x1, x2,z3.......xn是幂),那么一个数的因子数等于 ans = (x1+1)*(x2+1)*(x3+1)*......*(xn+1)。知道这样还不够,这样暴力写会TLE,咱还需要用到区间筛选,对,就是这样,打素数表时10^5会WA,需要打10^6的表,WA的心疼,,
代码:
#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N = 1000006;const LL p = 998244353;int pri[N], ispri[N], len;LL a[1000009], num[1000009];void init(){ memset(ispri, 0, sizeof(ispri)); len = 0; for(int i = 2; i <= 1000000; i++) { if(ispri[i]) continue; pri[len++] = i; for(int j = i*2; j <= 1000000; j += i) ispri[j] = 1; }}int main(){ init(); LL l, r, k; int t; scanf("%d", &t); while(t--) { scanf("%lld%lld%lld", &l, &r, &k); for(int i = 0; i <= r - l; i++) a[i] = l+i, num[i] = 1; for(int i = 0; i < len; i++) { LL s = l/pri[i]*pri[i]; if(s != l) s += pri[i]; for(LL j = s; j <= r; j += pri[i]) { LL w = 0; while(a[j-l] % pri[i] == 0) w++, a[j-l] /= pri[i]; num[j-l] = num[j-l] * ((1LL*w*k+1) % p) % p; } } LL ans = 0; for(int i = 0; i <= r-l; i++) if(a[i] != 1) num[i] = (num[i] * (k + 1)) % p; for(int i = 0; i <= r-l; i++) ans = (ans + num[i]) % p; printf("%lld\n", ans); } return 0;}
阅读全文
0 0
- hdu 6069 Counting Divisors(2017多校第四场)
- HDU 6069 Counting Divisors 多校联合第四场
- 2017 多校训练第四场 HDU 6069 Counting Divisors
- HDU6069多校第四场 Counting Divisors
- HDU -- 6069 Counting Divisors 【思维 + 二次筛法】多校第四场1003
- 2017杭电多校第四场1003 Counting Divisors (分解质因数) hdu 6069
- HDU 6069-Counting Divisors(多校训练第四场->区间质因数个数)
- HDU 6069 Counting Divisors 【2017多校联赛4】
- (hdu6069)2017杭电多校联赛第四场-Counting Divisors 因子个数求和(数论)
- hdu 6069 Counting Divisors
- [HDU]6069 Counting Divisors
- HDU 6069 Counting Divisors
- HDU 6069 Counting Divisors
- HDU-6069 Counting Divisors
- HDU 6069 Counting Divisors
- HDU-6069 Counting Divisors
- HDU 6069 Counting Divisors
- HDU 6069 Counting Divisors
- 二叉树的层次,中序非递归遍历,以递归前序的方式构造二叉树,将二叉树中的e更新为d,输出从根结点出发 到指定结点,依次经过的祖先(即路径),由前序和中序还原二叉树
- Bing it
- hdu 6134
- Zookeeper应用场景
- Java中throws和throw的区别
- hdu 6069 Counting Divisors(2017多校第四场)
- composer 安装 Laravel 出现的问题
- java中 IndexOf()、lastIndexOf()、substring()的用法
- Centos7安装Mysql5.7
- 丑数
- python any()和all()用法
- Linux中` `、$、$( ) 、${ } 有什么区别
- 1 ,js入门基础
- sqlserver数据库大型应用解决方案总结 数据库负载均衡