# 题目链接

https://lydsy.com/JudgeOnline/problem.php?id=4407

# 题解

$\sum_{T=1}^{\min(n,m)}\lfloor\frac{n}{T}\rfloor\lfloor\frac{m}{T}\rfloor\sum_{d|T}d^k\mu(\frac{T}{d})$

$f(T)=\sum_{d|T}d^k\mu(\frac{T}{d})$

# 代码

#include <cstdio>
#include <algorithm>

{
int x=0,f=1;
char ch=getchar();
while((ch<'0')||(ch>'9'))
{
if(ch=='-')
{
f=-f;
}
ch=getchar();
}
while((ch>='0')&&(ch<='9'))
{
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}

const int maxn=5000000;
const int mod=1000000007;

int quickpow(int a,int b)
{
int res=1;
while(b)
{
if(b&1)
{
res=1ll*res*a%mod;
}
a=1ll*a*a%mod;
b>>=1;
}
return res;
}

int k,p[maxn+10],prime[maxn+10],cnt,f[maxn+10];

int getprime()
{
p[1]=f[1]=1;
for(int i=2; i<=maxn; ++i)
{
if(!p[i])
{
prime[++cnt]=i;
f[i]=quickpow(i,k)-1;
if(f[i]<0)
{
f[i]+=mod;
}
}
for(int j=1; (j<=cnt)&&(i*prime[j]<=maxn); ++j)
{
int x=i*prime[j];
p[x]=1;
if(i%prime[j]==0)
{
f[x]=1ll*(f[prime[j]]+1)*f[i]%mod;
break;
}
f[x]=1ll*f[prime[j]]*f[i]%mod;
}
}
for(int i=1; i<=maxn; ++i)
{
f[i]+=f[i-1];
if(f[i]>=mod)
{
f[i]-=mod;
}
}
return 0;
}

int T,n,m;

int main()
{
getprime();
while(T--)
{