
【题目来源】https://www.luogu.com.cn/problem/P3935【题目描述】若 x 分解质因数结果为 x(p1^k1)×(p2^k2)×……×(pn^kn)令 f(x)(k11)(k21)⋯(kn1)求 ∑f(i) 对 998244353 取模的结果其中il~r。【输入格式】输入只有一行两个整数分别表示 l 和 r。【输出格式】输出一行一个整数表示答案。【输入样例】2 4【输出样例】7【数据范围】1≤l≤10^14l≤r≤1.6×10^14r−l10^14。【算法分析】● 整数分块算法https://blog.csdn.net/hnjzsyjyj/article/details/162819219● 若 x(p1^k1)×(p2^k2)×……×(pn^kn)则 f(x)(k11)(k21)⋯(kn1) 实际上就是 x 的约数个数。而约数个数和的经典公式为 ∑f(i)∑⌊n/i⌋其中 i1~n。● 约数个数定理https://blog.csdn.net/hnjzsyjyj/article/details/158127227【算法代码】#include bits/stdc.h using namespace std; typedef long long LL; const LL MOD998244353; LL cal(LL n) { LL t0; for(LL le1,ri0; len; leri1) { LL kn/le; rin/k; t(tk*((ri-le1)%MOD))%MOD; } return t; } int main() { ios::sync_with_stdio(0); cin.tie(0); LL le,ri; cinleri; LL ans(cal(ri)-cal(le-1)MOD)%MOD; coutans\n; return 0; } /* in:2 4 out:7 */【参考文献】https://blog.csdn.net/hnjzsyjyj/article/details/162819219https://blog.csdn.net/hnjzsyjyj/article/details/158127227