Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
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
The first line of the input contains an integer T(1≤T≤15), denoting the number of test cases. In each test case, there are 3 integers l,r,k(1≤l≤r≤1012,r−l≤106,1≤k≤107).
For each test case, print a single line containing an integer, denoting the answer.
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6069
题意: T 组测试数据,每组给出 l,r,k ,计算 l 到 r 每个数 k 次方的因子个数,并求和 可以推出规律:质数的 k 次方的因子个数为 k+1 比如求整数 a 的 k 次方的因子个数: 如果 a=6,k=2 ,则 36 的因子有 1,2,3,4,6,9,12,18,36 总共 9 个 如果将 6 分解质因子, 6=2*3 2,3 都是质数,所以 6 的平方的因子数为 (k+1)*(k+1) ,即 3*3=9 可以得出规律:如果 a 分解质因子为 a=p[1]^x*p[2]^y*p[3]^z (其中 p[1],p[2],p[3] 均为素数),则 a 的 k 次方的因子个数为: (x*k+1)*(y*k+1)*(z*k+1) ( a 的 k 次方分解质因子为 a^k=p[1]^(x*k)*p[2]^(y*k)*p[3]^(z*k) ) 所以可以将 l 到 r 每个数分解质因子,并记录每个质因子出现的次数,然后根据上面的规律计算出每个数 k 次方的因子个数,求和即可 由于数值比较大,这道题很容易时间超限,所以要注意求解的方法,还要不断取模