题目大意:设把$x$分解质因数的结果为$x=p_1^{k_1}p_2^{k_2}cdots p_n^{k_n}$,令$f(x)=(k_1+1)(k_2+1)cdots (k_n+1)$,求$sumlimits_{i=l}^r f(i)(1leqslant lleqslant 10^{14},1leqslant rleqslant 1.6 imes10^{14},r-l>10^{14}$
题解:可知$f(x)$为$x$的因数个数,可以把$sumlimits_{i=l}^rf(i)$拆成$sumlimits_{i=1}^rf(i)-sumlimits_{i=1}^lf(i)$。
$$
defdsum{displaystylesumlimits}
defdprod{displaystyleprodlimits}
egin{align*}
f(p)&=dprod_{i=1}^n(k_{p,i}+1)\
&=dsum_{i=1}^n[i|p]\
end{align*}\
带回原式
$$
$$
defdsum{displaystylesumlimits}
defdprod{displaystyleprodlimits}
egin{align*}
令g(p)&=dsum_{x=1}^pf(x)\
&=dsum_{x=1}^pdsum_{i=1}^x[i|x]\
&=dsum_{i=1}^piglfloordfrac p iig
floor\
end{align*}
$$
整除分块即可。
卡点:1.读入时忘记开$long;long$
C++ Code:
#include <cstdio> using namespace std; const int mod = 998244353; long long l, r; long long solve(long long n) { long long ans = 0, l, r; for (l = 1; l <= n; l = r + 1) { r = n / (n / l); ans = (ans + (r - (l - 1)) * (n / l)) % mod; } return ans; } int main() { scanf("%lld%lld", &l, &r); printf("%lld ", (solve(r) - solve(l - 1) + mod) % mod); return 0; }