Counting Divisors(hdu6069)

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, given l,r and k , your task is to calculate the following thing :

(i=lrd(ik))mod998244353

 

Input
The first line of the input contains an integer T(1T15) , denoting the number of test cases.

In each test case, there are 3 integers l,r,k(1lr1012,rl106,1k107) .
 

Output
For each test case, print a single line containing an integer, denoting the answer.
 

Sample Input
  
  
3 1 5 1 1 10 2 1 100 3
 

Sample Output
  
  
10 48 2302
解题思路:
http://www.7zhang.com/index/cms/read/id/429127.html
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long ll; int prime[1000005]; ll f[1000005],num[1000005],p[1000005]; ll mod=998244353; ll MAXN=1e6+5; int cnt; int main() {     memset(prime, 0, sizeof(prime));     cnt = 0;     prime[1] = 1;     for(ll i=2; i<1000005; i++)     {         if(!prime[i])         {             p[cnt++] = i;             for(ll j=i*i; j<MAXN; j+=i) prime[j] = 1;         }     }     int T;     scanf("%d",&T);     while(T--)     {         ll l,r,k;         scanf("%lld%lld%lld",&l,&r,&k);         ll ans=0;         if(l==1)         {ans++;l++;}         for(int i=0;i<=r-l;i++)         {             f[i]=i+l;             num[i]=1;         }         for(int i=0;i<cnt&&p[i]*p[i]<=r;i++)         {             ll tmp=l;           if(l%p[i]!=0)                 tmp=(l/p[i]+1)*p[i];//离l最近的含有p[i]因子的数             for(ll j=tmp;j<=r;j+=p[i])             {                 ll flag=0;                 while(f[j-l]%p[i]==0)                 {                     flag++;                     f[j-l]/=p[i];                 }                 num[j-l]=num[j-l]*(flag*k+1)%mod;             }         }         for(int i=0;i<=r-l;i++)         {             if(f[i]==1)             ans=(ans+num[i])%mod;             else                 ans=(ans+num[i]*(k+1)%mod)%mod;         }         printf("%lld\n",ans);     }     return 0; } k点击打开链接
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值