求:\(\sum_{i=1}^n\sum_{j=1}^m\mu(gcd(i,j))^2\)
化简可得\(\sum_{i=1}^{min(n,m)}{\lfloor \frac{n}{i} \rfloor}{\lfloor \frac{m}{i} \rfloor}\sum_{d|i}\mu(d)^2*\mu(\frac{i}{d})\)
有结论\(\sum_{d|n}\mu(d)^2*\mu(\frac{n}{d})=\sum_{i=1}^{\sqrt(n)}\mu(i)\)分块即可
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 998244353
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
//#define cd complex<double>
#define ull unsigned long long
//#define base 1000000000000000000
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}
using namespace std;
const double eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=4000000+10,maxn=200000+10,inf=0x3f3f3f3f;
bool mark[N];
int prime[N],cnt,mu[N];
void init()
{
mu[1]=1;
for(int i=2;i<N;i++)
{
if(!mark[i])prime[++cnt]=i,mu[i]=-1;
for(int j=1;j<=cnt&&i*prime[j]<N;j++)
{
mark[i*prime[j]]=1;
if(i%prime[j]==0)
{
mu[i*prime[j]]=0;
break;
}
mu[i*prime[j]]=-mu[i];
}
}
for(int i=1;i<N;i++)
{
mu[i]+=mu[i-1];
mu[i]=(mu[i]%mod+mod)%mod;
}
}
int main()
{
init();
ll n,m,ans=0;
scanf("%lld%lld",&n,&m);
if(n>m)swap(n,m);
for(ll i=1,j;i<=n;i=j+1)
{
j=min(n/(n/i),m/(m/i));
ll t1=(mu[(int)sqrt(j)]-mu[(int)sqrt(i-1)]+mod)%mod,t2=(n/i)%mod,t3=(m/i)%mod;
add(ans,t1*t2%mod*t3%mod);
}
printf("%lld\n",ans);
return 0;
}
/********************
********************/