显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXN (10000010)
#define MOD (998244353)
typedef long long LL;
inline void Init(void);
int phi[MAXN], N, M;
int prime[MAXN >> 1], cnt = 0;
bool flag[MAXN];
int main() {
#ifndef LOCAL
freopen("hoip.in", "r", stdin);
freopen("hoip.out", "w", stdout);
#endif
scanf("%d%d", &N, &M);
if(N > M) N ^= M ^= N ^= M;
Init();
LL ans = 0;
for(int i = 1; i <= N; ++i)
ans += (LL)phi[i] * (N / i)%MOD * (M / i)%MOD;
printf("%lld", ans%MOD);
return 0;
}
inline void Init(void) {
phi[1] = 1;
for(int i = 2; i <= N; ++i) {
if(!flag[i]) prime[++cnt] = i, phi[i] = i - 1;
for(int j = 1; j <= cnt && i * prime[j] <= N; ++j) {
flag[i * prime[j]] = true;
if(i % prime[j]) phi[i * prime[j]] = phi[i] * (prime[j] - 1);
else {
phi[i * prime[j]] = phi[i] * prime[j];
break;
}
}
}
return ;
}