多校的1003
来源:互联网 发布:网络金融检查自查报告 编辑:程序博客网 时间:2024/05/21 05:57
Counting Divisors
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
这道没写出来,不过用质数求约数的个数,用了快速幂的方法
#include<iostream>#include<map>#include <cstdio>#define mod 998244353#define ll long longusing namespace std;ll prime[100005]={2},P=1,N,Num;map<ll,ll> divisor;map<ll,ll>::iterator it;ll isPrime(ll N){ if(N % 3==0) return N==3; for(ll i=1;prime[i]*prime[i]<=N;++i) if( N % prime[i]==0) return 0; return 1;}ll divNum(ll Num){ for(ll i=0;prime[i]<=Num && i<P;++i) while( Num % prime[i] == 0 ){ divisor[prime[i]]++; Num /= prime[i]; } if(Num!=1) divisor[Num]=1; int result=1; for(it=divisor.begin();it!=divisor.end();++it) result *= (it->second + 1); divisor.clear(); return result;}ll quickpow(ll a, ll b){ ll ans=1, base=a; while(b!=0){ if(b&1!=0) ans*=base%mod; base*=base%mod; b>>=1; } return ans%mod;}int main(){ ll i; for(i=3;i<=1000000;i+=2) if(isPrime(i)) { prime[P++]=i; } int tcase; scanf("%d",&tcase); while(tcase--) { long long l, r, k; scanf("%lld%lld%lld",&l,&r,&k); long long cnt=0; for(i=l;i<=r;i++) { //printf("%d",quickpow(i, k)); cnt += divNum(quickpow(i,k))%mod; } printf("%lld\n",cnt); }
阅读全文
0 0
- 多校的1003
- 多校的第五题hdu4876
- 陈老师的多校联合 20140809
- 久违的题解 多校联考
- 多校中保存的读入挂
- 多校联赛2 Problem2 Warm up 求桥的数目+缩点后的树的直径 当时被不知道原因的爆栈爆到无语了。。
- 查找——相邻元素差的绝对值都是1的数组当中的某个数的索引——多益网络2018校招编程1
- 从多校联合NUDT第二题Cube想到的关于树状数组的结论
- 多校第三场:hdu 4320(小数的进制转换,有限小数的条件)
- 一道优先队列的题...- 2013ACM多校联合(4)_NUN - ZZ的橱柜
- 陈老师的多校联合20140816||SPOJ AMR11B 三角形的有向面积
- 1003 神奇的植物
- 1003-Hive的安装
- 【1003】相连的1
- 偷摸的回校,打枪的不要!
- apk的classes.dex的校检
- 多校联合(4) ZZ的橱柜
- 多校联合 Park Visit (求树的最长路径)
- 常用函数
- 数据类型与数据传送指令
- jQuery是什么?
- appStore审核被拒的原因
- 八种排序算法Java实现-二分插入排序
- 多校的1003
- spring ioc原理(看完后大家可以自己写一个spring)
- Linux快捷键
- 耦合
- python学习日志(一)
- The Meeting Place Cannot Be Changed
- 怎样做好网站导航条优化
- Python-uiautomator使用说明文档
- PHP邮件发送那点事