http://acm.hdu.edu.cn/showproblem.php?pid=2421
唯一分解定理: ;其中pi为质数
n的正约数个数:
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e4+7;
ll e[1005];
ll factor[1005];
int main()
{
ll a,b;
int cas=1;
while(~scanf("%lld%lld",&a,&b))
{
if(a==1)
{
printf("Case %d: 1\n",cas++);
continue;
}
ll t=sqrt(a+0.5);
ll num=0,numf=0;
for(ll i=2;i<=t;i++)
{
if(a%i==0)
{
factor[numf++]=i;
if(i*i!=a)
factor[numf++]=a/i;
}
}
factor[numf++]=a;
sort(factor,factor+numf);
for(ll i=0;i<numf;i++)
{
ll num0=0;
while(a%factor[i]==0)
{
num0++;
a/=factor[i];
}
e[num++]=num0*b;
}
ll ans=1;
for(ll i=0;i<num;i++)
{
ll n=(e[i]+1)*(e[i]+2)/2;
n%=N;
n*=n;
n%=N;
ans*=n;
ans%=N;
}
printf("Case %d: %lld\n",cas++,ans);
}
return 0;
}