提交时间:2024-02-27 13:33:33
运行 ID: 26919
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define x1 x114514 #define y1 y114514 #define p_b push_back #define m_p make_pair #define uint unsigned int using namespace std; typedef long long ll; const int maxn=2e5+10; inline ll read(){ ll x=0;short t=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; }int n,m,miu[maxn],pr[maxn],ct,b[maxn]; uint f[maxn],g[maxn]; vector<pi>P[maxn]; void init(){ up(i,1,2e5){ int x=i; for(int j=2;j*j<=x;++j){ if(x%j==0){ int ct=0; while(x%j==0)x/=j,ct++; P[i].p_b(m_p(j,ct)); } }if(x!=1)P[i].p_b(m_p(x,1)); }miu[1]=1; up(i,2,2e5){ if(!b[i])pr[++ct]=i,miu[i]=-1; up(j,1,ct){ if(i*pr[j]>2e5)break; b[i*pr[j]]=1; miu[i*pr[j]]=-miu[i]; if(!(i%pr[j])){miu[i*pr[j]]=0;break;} } } } uint d(int x){ uint res=1; for(auto it:P[x])res=res*(it.p2*2+1); return res; } void slv(){ n=read(),m=read(); up(i,1,n){ f[i]=0; for(int j=1;j<=n/i;++j)f[i]+=d(i*j); }up(i,1,m){ g[i]=0; for(int j=1;j<=m/i;++j)g[i]+=d(i*j); }uint res=0; up(i,1,n){ uint s1=0,s2=0; up(x,1,n/i)s1+=f[i*x]; up(y,1,m/i)s2+=g[i*y]; res+=s1*s2*miu[i]; } printf("%d\n",int(res%1073741824)); }int main(){ // freopen("math.in","r",stdin); // freopen("math.out","w",stdout); init();int t=read();while(t--)slv(); fclose(stdin); fclose(stdout); return 0; }