Pagini recente » Cod sursa (job #2521449) | Cod sursa (job #42560) | Cod sursa (job #1864690) | Cod sursa (job #1843049) | Cod sursa (job #1928041)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
const int mod=9901;
int p2,A,B,c,pr[20],pu[20],prod,fix,k,sum,i,t,fact;
long long p;
int expo(int a,long long b)
{
p2=a%mod;prod=1;
for(p=0;(1LL<<p)<=b;p++)
{
if(((1LL<<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;
A=1;
}
c++;
}
sum=1;
for(i=1;i<=k;i++)
{
t=pr[i]-1;
while(t%mod==0)
t/=mod;
fact=(expo(pr[i],B*pu[i]+1)-1)%mod;
if(fact<0) fact+=mod;
sum=(sum*fact)%mod;
sum=(sum*expo(t,mod-2))%mod;
}
g<<sum;
return 0;
}