https://www.luogu.org/fe/problem/P3935
求:
\(F(n)=\sum\limits_{i=1}^{n}d(i)\)
枚举因子\(d\),每个因子\(d\)都给其倍数贡献\(1\),倍数一共有\(\lfloor\frac{n}{d}\rfloor\)个。
\(F(n)=\sum\limits_{d=1}^{n}\lfloor\frac{n}{d}\rfloor\)
套个分块,上。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
ll F(ll n){
ll res=0;
for(ll l=1,r;l<=n;l=r+1){
ll t=n/l;
r=n/t;
res+=t*(r-l+1);
if(res>=mod)
res%=mod;
}
return res;
}
int main() {
#ifdef Yinku
freopen("Yinku.in","r",stdin);
#endif // Yinku
ll l,r;
scanf("%lld%lld\n",&l,&r);
printf("%lld\n",(F(r)-F(l-1)+mod)%mod);
return 0;
}