Pagini recente » Cod sursa (job #366769) | cni_preoji | Cod sursa (job #2069595) | Cod sursa (job #463489) | Cod sursa (job #1060878)
#include<cstdio>
#define MOD 9901
#define LL long long
#include<bitset>
#include<vector>
using namespace std;
bitset<10010> notprim;
vector<int> V;
LL result,i,exp,A,B;
LL pow(LL x,LL y)
{
long long res=1;
for(;y;y>>=1)
{
if(y&1)
res=(res*x)%MOD;
x=(1LL*x*x)%MOD;
}
return res;
}
void precalculeazaPrim()
{
V.push_back(2);
int i,j;
for(i=3;i<=10000;i+=2)
{
if(i&1 && !notprim[i])
{
V.push_back(i);
for(j=i*i;j<=10000;j+=i)
notprim[j]=1;
}
}
}
int main()
{
freopen("sumdiv.in","r",stdin);
freopen("sumdiv.out","w",stdout);
precalculeazaPrim();
scanf("%lld%lld",&A,&B);
if(!A){printf("0\n");return 0;}
if(A==1){printf("1\n");return 0;}
result=1LL;
for(vector<int>::iterator it=V.begin();it!=V.end();it++)
{
i=*it;
if(i>A)break;
for(exp=0;!(A%i);exp++,A/=i);
if(exp)
{
LL g=(pow(i,exp*B+1)-1)%MOD;
if(g<0)g+=MOD;
result=(result*g)%MOD;
result=(result*pow(i-1,MOD-2))%MOD;
}
}
if(A>1 && A%MOD==1)
{
result=(result*(B%MOD+1))%MOD;
}
else
if(A>1)
{
LL g=(pow(A,B+1)-1)%MOD;
if(g<0)g+=MOD;
result=(result*g)%MOD;
result=(result*pow(A-1,MOD-2))%MOD;
}
printf("%lld\n",result);
return 0;
}