Pagini recente » Cod sursa (job #1914359) | Cod sursa (job #1334199) | Cod sursa (job #286296) | Cod sursa (job #839245) | Cod sursa (job #1928113)
#include <iostream>
#include <fstream>
#include <cmath>
#include <cassert>
using namespace std;
const long long mod=9901;
long long p2,A,B,c,pr[30],pu[30],prod,fix,k,sum,i,t,fact,moda,proda,p2a;
long long p;
int expo(long long a,long long b)
{
p2=a%mod;prod=1;moda=9901*9901;proda=1;p2a=a%moda;
for(p=0;(1LL<<p)<=b;p++)
{
if(((1LL<<p)&b))
prod=(1LL*prod*p2)%mod,proda=(1LL*proda*p2a)%moda;
p2=(1LL*p2*p2)%mod;
p2a=(1LL*p2a*p2a)%moda;
}
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],1LL*(B*pu[i]+1))-1)%mod;
if(fact<0) fact+=mod;
sum=(sum*fact)%mod;
if(proda==1) {g<<'0';return 0;}
sum=(sum*expo(t,mod-2))%mod;
}
g<<sum;
return 0;
}