题目大意:
给定 t 组数据,每组数据由一个n(下文中的x),一个c构成,计算分段函数
比赛的时候不认真看题,导致会错意了。。
比赛结束看了题解才明白
观察公式,fc(x) 其实是c 的若干次方,且指数要尽量大。最好的情况下,每次只消掉一个质因子。所以fc(x)=c^x的质因子个数
题目代码:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
const long long mod=1e9+7;
int qpow(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 main()
{
int t,x,c,f;
long long ans;
scanf("%d",&t);
while(t--)
{
int cnt=0;
ans=1;
scanf("%d%d",&x,&c);
if(x==1)
cout<<1<<endl;
else
{
int j;
for(j=2;j*j<=x;j++)
{
while(x%j==0)
{
x=x/j;
ans=(ans*c)%mod;
}
}
if(x>1)
ans=(ans*c)%mod
printf("%lld\n",ans);
}
}
return 0;
}