#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 i<=sqrt(M)については愚直にやる(M/k>=sqrt(M)) i>sqrt(M)ではM/k> N >> M; mint ans=0, S, iv=mint(2).inv(); K = isqrt(M); for (int i=1; i<=min(K, N); i++){ if (M/i <= K) continue; 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; }