#include #include using namespace std; using ll = long long; using namespace atcoder; using mint = modint998244353; //calculate floor(sqrt(s)) ll isqrt(ll s){ ll l=0, r=3e9, c; while(r-l>1){ c = (l+r)/2; if (c*c <= s) l = c; else r = c; } return l; } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); /* sum(i=1, N)(M-(M/k)k)=MN-sum(i=1,N)(M/k)k M/iがsqrt(M-1)以下のiはO(sqrt(M))個しかないので愚直にやる。 1<=j<=sqrt(M)に対して、M/k=jとなるkをまとめて j*(kの総和) j<=M/k> N >> M; mint ans=0, S, iv=mint(2).inv(); K = isqrt(M); for (int i=1; i<=1e9; i++){ if (M/i <= K) break; ans += (M/i)*i; } for (int j=K; j>=1; j--){ L = M/(j+1)+1; R = min(M/j, N); if (L>R) continue; //L~Rの和 S = mint(R)*(R+1)*iv-mint(L)*(L-1)*iv; ans += S*j; } cout << (mint(N)*M-ans).val() << endl; return 0; }