标签:preview ott ati 大于 esc arc nbsp sub lin
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 3041 Accepted Submission(s): 1130
1 #include<bits/stdc++.h> 2 3 typedef long long ll; 4 using namespace std; 5 6 const int N=1e6+5; 7 const int inf=1e9; 8 const int mod=998244353; 9 10 ll l,r,k; 11 bool v[N]; 12 ll ans[N]; 13 ll num[N]; 14 int pri[N]; 15 int pcnt; 16 void init() 17 { 18 pcnt = 0;//素数筛 19 for(int i = 2; i <= N; i++) 20 { 21 if(!v[i]) 22 pri[pcnt++] = i; 23 for(int j = 0; j < pcnt && pri[j] <= N/i; j++) 24 { 25 v[i*pri[j]] = 1; 26 if(i % pri[j]==0) break; 27 } 28 } 29 } 30 void f() 31 { 32 for(ll i=l;i<=r;i++)//初始化记录数组 33 num[i-l]=i,ans[i-l]=1; 34 } 35 int main() 36 { 37 int t; 38 init(); 39 scanf("%d",&t); 40 while(t--) 41 { 42 scanf("%lld%lld%lld",&l,&r,&k); 43 f(); 44 for(int i=0;i<pcnt&&pri[i]<=1000000;i++){//限制质因子大小 45 ll p=pri[i]; 46 ll d=l/p+(l%p>0); 47 if(d==1) d=2;//l<=p 的情况在最后判断处理 48 for(ll j=d*p;j<=r;j+=p){ 49 ll cnt=0; 50 while(num[j-l]%p==0){ 51 num[j-l]/=p; 52 cnt++; 53 } 54 ans[j-l]=(ans[j-l]%mod)*((1+k*cnt)%mod)%mod; 55 } 56 } 57 ll sum=0; 58 for(ll i=l;i<=r;i++){ 59 if(num[i-l]>1)//还存在一个大于1000000的因子,再乘上k+1 60 sum=(sum+ans[i-l]*(k+1))%mod; 61 else 62 sum=(sum+ans[i-l])%mod; 63 } 64 printf("%lld\n",sum); 65 } 66 67 }
标签:preview ott ati 大于 esc arc nbsp sub lin
原文地址:http://www.cnblogs.com/mj-liylho/p/7324808.html