显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD=998244353;
const int maxn=1e7+5;
int n,m;
ll ans;
ll phi[maxn],prime[maxn],cnt;
bool flag[maxn];
void phi_table(int n)
{
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]]=1;
if(i%prime[j]==0)
{
phi[i*prime[j]]=(phi[i]*prime[j])%MOD;
break;
}
else phi[i*prime[j]]=(phi[i]*(prime[j]-1))%MOD;
}
}
}
int main()
{
freopen("hoip.in","r",stdin);
freopen("hoip.out","w",stdout);
scanf("%d%d",&n,&m);
if(n>m)
{
ll a=n;
n=m;
m=a;
}
phi_table(n);
for(int i=1;i<=n;i++)
{
ans+=phi[i]*(n/i)%MOD*(m/i)%MOD;
ans%=MOD;
}
printf("%lld",ans%MOD);
return 0;
}