Pagini recente » Cod sursa (job #2446388) | Cod sursa (job #612905) | Cod sursa (job #988473) | Cod sursa (job #350404) | Cod sursa (job #1928022)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
const int mod=9901;
int p2,A,B,p,c,pr[20],pu[20],prod,fix,k,sum,i,t;
int expo(int a,int b)
{
p2=a%mod;prod=1;
for(p=0;(1<<p)<=b;p++)
{
if(((1<<p)&b))
prod=(prod*p2)%mod;
p2=(p2*p2)%mod;
}
return prod;
}
int main()
{
ifstream f("sumdiv.in");
ofstream g("sumdiv.out");
f>>A>>B;
fix=sqrt(A);c=2;
while(A!=1)
{
if(A%c==0)
{
k++;pr[k]=c;
while(A%c==0)
{
A/=c;
pu[k]++;
}
}
if(c>fix&&A!=1)
{
k++;
pr[k]=A;
pu[k]=1;
pr[k]=1;
A=1;
}
c++;
}
sum=1;
for(i=1;i<=k;i++)
{
t=pr[i]-1;
while(t%mod==0)
t/=mod;
sum=(sum*expo(pr[i],B*pu[i]+1))%mod;
sum=(sum*expo(t,mod-2))%mod;
}
g<<sum;
return 0;
}