Hdu6069 Counting Divisors(2017多校第4场)
来源:互联网 发布:哪里有im域名 编辑:程序博客网 时间:2024/06/08 12:22
Counting Divisors
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1105 Accepted Submission(s): 393
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
—————————————————————————————————
题目的意思是求一个区间的每个数的因子数之和
思路:先去打一个1到1e6的素数表,然后去枚举每个素数在区间内的倍数,可以跳着枚举,计算出每个数对应的因子个数,对于每个数的因子个数就等于枚举的因子个数*k+1累乘起来,注意剩下的大素数的判断
比赛是也是素数打表枚举的 ,鬼知道怎么想的去枚举区间的每个数去求因子,妥妥TLE,也有过正解的想法,想过没想太透彻,感觉这种题值得好好反思警戒自己
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <map>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;const LL mod = 998244353;bool vis[1000009];LL prime[1000009], sum[1000009], a[1000009];LL l, r, k;int cnt;void init(){ memset(vis, true, sizeof vis); vis[0] = vis[1] = false; cnt = 0; for (int i = 2; i < 1000009; i++) { if (!vis[i]) continue; prime[cnt++] = i; for (int j = i * 2; j < 1000009; j += i) vis[j] = false; }}int main(){ init(); int t; scanf("%d", &t); while (t--) { scanf("%lld%lld%lld", &l, &r, &k); for (int i = 0; i <= r - l; i++) sum[i] = 1, a[i] = i + l; LL ans = 0; for (int i = 0; i < cnt; i++) { LL p = (l / prime[i] + (l%prime[i] ? 1 : 0))*prime[i]; for (LL j = p; j <= r; j += prime[i]) { int res = 0; while (a[j - l] % prime[i] == 0) res++, a[j - l] /= prime[i]; sum[j - l] = sum[j - l] * ((1LL * res*k + 1) % mod) % mod; } } for (int i = 0; i <= r - l; i++) { if (a[i] != 1) sum[i] = sum[i] * (k + 1) % mod; ans = (ans + sum[i]) % mod; } printf("%lld\n", ans); } return 0;}
阅读全文
0 0
- Hdu6069 Counting Divisors(2017多校第4场)
- Counting Divisors(hdu6069)
- (hdu6069)2017杭电多校联赛第四场-Counting Divisors 因子个数求和(数论)
- HDU6069多校第四场 Counting Divisors
- hdu6069 Counting Divisors(数学)
- HDU6069---Counting Divisors(2017多校联赛:数学)
- HDU6069 Counting Divisors(区间素数筛)
- HDU6069-Counting Divisors(约数个数定理)
- HDU6069 Counting Divisors
- hdu6069 Counting Divisors
- HDU6069 Counting Divisors【数学】
- HDU6069-Counting Divisors
- hdu6069 Counting Divisors
- hdu6069 Counting Divisors && lightoj1028
- 2017多校训练Contest4: 1003 Counting Divisors hdu6069
- HDU6069 Counting Divisors(素数筛+二次筛)
- HDU6069-区间筛&&因子公式-Counting Divisors
- HDU6069 Counting Divisors 区间素数筛法
- CSU-ACM2017暑假集训比赛2 CodeForces
- 复制文档
- 矩阵快速幂 模板
- 磁盘管理3--磁盘配额
- HTML5 实现跨域消息传递
- Hdu6069 Counting Divisors(2017多校第4场)
- 拷贝图片
- 由View.post引发的问题
- Guided Image Filtering
- 树状数组--区间加单点询问
- 【HDU1233】还是畅通工程(最小生成树-水题)
- PAT 5-19
- 最大连续子数列和 模板
- 关于i++ 跟++i 的区别。