https://www.luogu.org/fe/problem/P3935
求:
(F(n)=sumlimits_{i=1}^{n}d(i))
枚举因子(d),每个因子(d)都给其倍数贡献(1),倍数一共有(lfloorfrac{n}{d}
floor)个。
(F(n)=sumlimits_{d=1}^{n}lfloorfrac{n}{d}
floor)
套个分块,上。
#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
",&l,&r);
printf("%lld
",(F(r)-F(l-1)+mod)%mod);
return 0;
}