| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
AC代码#include<iostream>
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;
const int maxn=1e4+10,MOD=9901;
struct Prime{
int p,c;
}prime[maxn];
int n,m,k;
LL power(int a,int b)
{
LL Qp=1;
for( ; b ;b >>= 1){
if(b & 1) Qp=(long long)Qp*a%MOD;
a=(long long)a*a%MOD;
}
return Qp;
}
int sum(LL p,LL c)
{
if(c==0) return 1;
if(c%2==1)
return ((1+power(p,(c+1)/2))*sum(p,(c-1)/2))%MOD;
if(c%2==0)
return ((1+power(p,c/2))*sum(p,(c/2)-1)+power(p,c))%MOD;
}
void divide()
{
k=0;
memset(prime,0,sizeof(prime));
for(int i=2;i*i<=n+1;i++){
if(n%i==0){
prime[++k].p=i;
while(n%i==0) n/=i,prime[k].c+=1;
}
}
if(n>1){
prime[++k].p=n;
prime[k].c=1;
}
}
int main()
{
while(scanf("%d%d",&n,&m)!=EOF){
int ans=1;
divide();
for(int i=1;i<=k;i++){
ans=(ans*sum(prime[i].p,prime[i].c*m))%MOD;
}
printf("%d\n",ans);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator