HDU 6069-Counting Divisors(多校训练第四场->区间质因数个数)
来源:互联网 发布:python 服务 编辑:程序博客网 时间:2024/06/06 07:03
Counting Divisors
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1952 Accepted Submission(s): 710
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
题意:见题面吧。。。
题解:比赛的时候简直智障,感觉暴力必定过不了我就没太敢下手,后来现场搞一发Pollard_rho算法,改了将近一个多小时,还是TLE,这么难!!!果断放弃了。(还是太菜),今天补了这道题,发现和暴力的唯一区别就是区间枚举质因数的时候不是++,而是+p,woc,为什么比赛的时候没想到,就一个字母的事情,真的是菜菜菜菜菜菜啊。。。
我当时是怎么想的,直接在区间里枚举当前质因数的倍数就好了233333.。。。
#include<map> #include<stack> #include<queue> #include<vector> #include<math.h> #include<time.h> #include<stdio.h> #include<iostream> #include<string.h> #include<stdlib.h> #include<algorithm> using namespace std; typedef long long ll; #define inf 2147483647 #define mod 998244353 #define maxn 1000005 #define lowbit(x) (x&-x) #define eps 1e-10 ll a[maxn]={1,1},b[maxn],c[maxn],d[maxn];int main(void){ll T,l,r,i,j,ans,cnt=0,tmp,k,res;for(i=2;i<=maxn;i++){if(a[i])continue;b[++cnt]=i;for(j=i*i;j<=maxn;j+=i)a[j]=1;}scanf("%lld",&T);while(T--){ans=0;scanf("%lld%lld%lld",&l,&r,&k);for(i=l;i<=r;i++)c[i-l]=i,d[i-l]=1;for(i=1;b[i]*b[i]<=r && i<=cnt;i++){tmp=l-l%b[i];if(tmp<l)tmp+=b[i];for(j=tmp;j<=r;j+=b[i]){res=0;if(c[j-l]%b[i]==0){while(c[j-l]%b[i]==0)c[j-l]/=b[i],res++;d[j-l]=(d[j-l]*(1+k*res))%mod;}}}for(i=l;i<=r;i++)if(c[i-l]>1)d[i-l]=(d[i-l]*(1+k))%mod;for(i=l;i<=r;i++)ans=(ans+d[i-l])%mod;printf("%lld\n",ans);}return 0;}
阅读全文
1 0
- HDU 6069-Counting Divisors(多校训练第四场->区间质因数个数)
- 2017 多校训练第四场 HDU 6069 Counting Divisors
- 2017杭电多校第四场1003 Counting Divisors (分解质因数) hdu 6069
- hdu 6069 Counting Divisors(2017多校第四场)
- HDU-2017 多校训练赛4-1003-Counting Divisors
- HDU 6069 Counting Divisors 多校联合第四场
- (2017多校训练第四场)HDU
- (2017多校训练第四场)HDU
- HDU -- 6069 Counting Divisors 【思维 + 二次筛法】多校第四场1003
- HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)
- 2017多校训练Contest4: 1003 Counting Divisors hdu6069
- HDU6069多校第四场 Counting Divisors
- HDU 5335(2015 ACM多校训练第四场1009)
- 2017多校训练赛第四场 HDU 6071(最短路)
- HDU 6070-Dirt Ratio(多校训练第四场->二分+线段树)
- 2017多校训练赛第四场 HDU 6070(二分答案+线段树+扫描线)
- 2017多校训练赛第四场 HDU 6078 Wavel Sequence(dp+优化)
- 2015 ACM多校训练第四场
- Flume直接到SparkStreaming的两种方式
- 002-20161115-2光明回应读者无限关于“佛家、道家,道家三清”的问题
- RSA实践
- ros 节点实现简易超声雷达串口通讯 模拟出激光雷达消息
- fancyTree学习笔记
- HDU 6069-Counting Divisors(多校训练第四场->区间质因数个数)
- SPI总线 的使用 和 裸机程序编写
- JVM调优:选择合适的GC collector (三)
- ios文字设置渐变色
- BZOJ 2301 [HAOI2011]Problem b (莫比乌斯反演)
- 1177: 按要求排序(指针专题)
- Linux环境安装nginx
- InternetReadFile 处理大数据
- Eclipse上的EGit插件使用详解