题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2154
题意:
思路:
i64 mou[N];
void init(int N)
{
i64 i,j;
for(i=2;i<=N;i++) if(!mou[i])
{
mou[i]=i;
for(j=i*i;j<=N;j+=i) mou[j]=i;
}
mou[1]=1;
for(i=2;i<=N;i++)
{
if(i/mou[i]%mou[i]==0) mou[i]=0;
else mou[i]=-mou[i/mou[i]];
}
for(i=1;i<=N;i++) mou[i]=(mou[i-1]+mou[i]*i%mod*i%mod)%mod;
}
i64 n,m;
i64 Sum(i64 n,i64 m)
{
n=n*(n+1)/2%mod;
m=m*(m+1)/2%mod;
return n*m%mod;
}
i64 F(i64 n,i64 m)
{
i64 ans=0,L,R;
for(L=1;L<=n;L=R+1)
{
R=min(n/(n/L),m/(m/L));
ans+=(mou[R]-mou[L-1])%mod*Sum(n/L,m/L)%mod;
ans%=mod;
}
return ans;
}
int main()
{
RD(n,m);
if(n>m) swap(n,m); init(m);
i64 ans=0,L,R;
for(L=1;L<=n;L=R+1)
{
R=min(n/(n/L),m/(m/L));
ans+=(L+R)*(R-L+1)/2%mod*F(n/L,m/L)%mod;
ans%=mod;
}
if(ans<0) ans+=mod;
PR(ans);
}