显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#define MOD 998244353
using namespace std;
const int maxn=1e7+10;
int n,m,cnt;
long long ans;
long long phi[maxn],prime[maxn];
void solve()
{
phi[1]=1;
for(register int i=2;i<=n;i++)
{
if(!phi[i]) phi[i]=i-1,prime[++cnt]=i;
for(register int j=1;j<=cnt&&i*prime[j]<=n;j++)
{
if(i%prime[j]==0)
{
phi[i*prime[j]]=phi[i]*prime[j];
break;
}
else phi[i*prime[j]]=phi[i]*(prime[j]-1);
}
}
}
int main()
{
freopen("hoip.in","r",stdin);
freopen("hoip.out","w",stdout);
scanf("%d%d",&n,&m);
if(n>m) swap(n,m);
solve();
for(register int i=1;i<=n;i++) ans=(ans+(phi[i]%MOD*(n/i)%MOD)*(m/i)%MOD)%MOD;
printf("%d\n",ans);
return 0;
}