constint p = 998244353; inlineintadd(int x, int y){ return (x += y) >= p ? x - p : x; } inlineintmul(int x, int y){ return1ll * x * y % p; } inlineintadd(initializer_list<int> lst){ int s = 0; for (auto t : lst) s = add(s, t); return s; } inlineintmul(initializer_list<int> lst){ int s = 1; for (auto t : lst) s = mul(s, t); return s; } intpow_mod(int x, int n){ int s = 1; for (; n; n >>= 1, x = mul(x, x)) if (n & 1) s = mul(s, x); return s; }
int pri[maxn], phi[maxn], cnt, f[maxn]; bool isp[maxn]; voidinit_isp(int n){ phi[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i, phi[i] = i - 1; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) { phi[i * pri[j]] = phi[i] * pri[j]; break; } phi[i * pri[j]] = phi[i] * (pri[j] - 1); } } constint inv2 = pow_mod(2, p - 2); for (int i = 1; i <= n; ++i) for (int j = i; j <= n; j += i) f[j] = add(f[j], mul({ (i == j) + phi[j / i], j / i, inv2 })); for (int i = 1; i <= n; ++i) f[i] = mul(f[i], i); }