显示代码纯文本
#include<bits/stdc++.h>
#define int long long
using namespace std;
int ph[10000005],cnt,prime[10000050];
void euler(int n)
{
ph[1]=1;
for(int i=2;i<=n;i++)
{
if(ph[i]==0)ph[i]=i-1,prime[++cnt]=i;
for(int j=1;j<=cnt&&i*prime[j]<=n;j++)
{
if(i%prime[j]==0)
{
ph[i*prime[j]]=prime[j]*ph[i];
break;
}
else ph[i*prime[j]]=(prime[j]-1)*ph[i];
}
}
}
signed main()
{
freopen("hoip.in","r",stdin);
freopen("hoip.out","w",stdout);
int ans=0,n,m;
cin>>n>>m;
euler(min(n,m));
for(int i=1;i<=min(n,m);i++)
{
ans=(ans+ph[i]*(m/i)*(n/i))%998244353;
}
cout<<ans;
return 0;
}