#include<iostream> #include<vector> #define maxn 100010 #define ll long long usingnamespacestd;
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], cnt, phi[maxn], mu[maxn]; bool isp[maxn]; voidinit_isp(int n){ phi[1] = mu[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i, phi[i] = i - 1, mu[i] = p - 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); mu[i * pri[j]] = p - mu[i]; } } }
constint B = 50; int f[maxn]; vector<int> g[maxn], pre[B + 1][B + 1]; voidinit(int n){ init_isp(n); for (int i = 1; i <= n; ++i) { int t = mul(i, pow_mod(phi[i], p - 2)); for (int j = i; j <= n; j += i) f[j] = add(f[j], mul(t, mu[j / i])); } //for (int i = 1; i <= n; ++i) sf[i] = add(sf[i - 1], f[i]); for (int i = 1; i <= n; ++i) { g[i].resize(n / i + 1); for (int j = 1; i * j <= n; ++j) g[i][j] = add(g[i][j - 1], phi[i * j]); } for (int j = 1; j <= B; ++j) for (int k = j; k <= B; ++k) { pre[j][k].resize(n / k + 1); for (int i = 1; i <= n / k; ++i) pre[j][k][i] = add(pre[j][k][i - 1], mul({ f[i], g[i][j], g[i][k] })); } }
int n, m;
voidwork(){ cin >> n >> m; int ans = 0; if (n > m) swap(n, m); for (int l = 1, r; l <= n; l = r + 1) { r = min(n / (n / l), m / (m / l)); if (m / l <= B) { ans = add({ ans, pre[n / l][m / l][r], p - pre[n / l][m / l][l - 1] }); } else { for (int i = l; i <= r; ++i) ans = add(ans, mul({ f[i], g[i][n / l], g[i][m / l] })); } } cout << ans << "\n"; }