2017杭电多校第四场1003 Counting Divisors (分解质因数) hdu 6069
来源:互联网 发布:js 设置div class 编辑:程序博客网 时间:2024/06/08 14:43
Counting Divisors
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1374 Accepted Submission(s): 495
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: 6079 6078 6077 6076 6075
题意:求那个公式
解题思路:设n=pc11pc22...pcmmn=p ,则d(nk)=(kc1+1)(kc2+1)...(kcm+1) 枚举不超过r√ 的所有质数p ,再枚举区间[l,r] 中所有p 的倍数,将其分解质因数,最后剩下的部分就是超过r√ 的质数,只可能是0 个或1 个。
时间复杂度O(r√+(r−l+1)loglog(r−l+1))
时间复杂度
#include<cstdio>typedef long long ll;const int N=1000010,P=998244353;int Case,i,j,k,p[N/10],tot,g[N],ans;ll n,l,r,f[N];bool v[N];inline void work(ll p){ for(ll i=l/p*p;i<=r;i+=p)if(i>=l){ int o=0; while(f[i-l]%p==0)f[i-l]/=p,o++; g[i-l]=1LL*g[i-l]*(o*k+1)%P;//i的因子个数 }}int main(){//枚举到N的所有质数 for(i=2;i<N;i++){ if(!v[i])p[tot++]=i; for(j=0;j<tot&&i*p[j]<N;j++){ v[i*p[j]]=1; if(i%p[j]==0)break; } } scanf("%d",&Case); while(Case--){ scanf("%lld%lld%d",&l,&r,&k); n=r-l; for(i=0;i<=n;i++)f[i]=i+l,g[i]=1; for(i=0;i<tot;i++){ if(1LL*p[i]*p[i]>r)break; work(p[i]); } for(ans=i=0;i<=n;i++){ if(f[i]>1)g[i]=1LL*g[i]*(k+1)%P; ans=(ans+g[i])%P; } printf("%d\n",ans); } return 0;}
阅读全文
1 0
- 2017杭电多校第四场1003 Counting Divisors (分解质因数) hdu 6069
- 2017多校四 1003题 hdu 6069 Counting Divisors 分解质因数
- HDU 6069-Counting Divisors(多校训练第四场->区间质因数个数)
- hdu 6069 Counting Divisors(2017多校第四场)
- 2017 多校训练第四场 HDU 6069 Counting Divisors
- HDU 6069 Counting Divisors 多校联合第四场
- HDU -- 6069 Counting Divisors 【思维 + 二次筛法】多校第四场1003
- (hdu6069)2017杭电多校联赛第四场-Counting Divisors 因子个数求和(数论)
- hdu6069 Counting Divisors 质因数分解 区间筛
- HDU6069多校第四场 Counting Divisors
- HDU 4432 Sum of 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
- OkHttp3的简单封装
- 【枚举情况】UVALive
- matlab画图的一些问题【归纳整理前辈的一些东西】
- java基础复习--数组的二分查找
- 其它函数
- 2017杭电多校第四场1003 Counting Divisors (分解质因数) hdu 6069
- LabVIEW面向对象的一些精华文章
- 【转】Servlet和Jsp的关系
- Android中使用Handler(消息机制)造成内存泄露的分析和解决
- HDU 1466 计算直线的交点数(动态规划)
- 自定义view画圆 单点拖动
- 面
- 玩转ProgressBar,设置渐变效果,同时设置两个进度的颜色显示!!!
- QT学习记录三