显示代码纯文本
#include <cmath>
#include <cstdio>
#include <iostream>
#define maxn 10000005
#define mod 998244353ll
using namespace std;
inline int read(){
int op=1,aa=0;
char c=getchar();
while(c<'0'||c>'9'){if(c=='-')op=-1;c=getchar();}
while(c>='0'&&c<='9'){aa=aa*10+c-'0';c=getchar();}
return op*aa;
}
int n,m;
int cnt;
int phi[maxn];
int prime[maxn];
void phi_table(int x){
phi[1]=1;
for(int i=2;i<=x;i++){
if(!phi[i]){
phi[i]=i-1;
prime[++cnt]=i;
}
for(int j=1;j<=cnt&&i*prime[j]<=x;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);
n=read(),m=read();
if(n>m)swap(n,m);
phi_table(n);
long long ans=0;
for(int i=1;i<=n;i++){
ans+=1ll*phi[i]*(m/i)%mod*(n/i)%mod;
ans%=mod;
}
cout<<ans<<'\n';
return 0;
}