Pagini recente » Atasamentele paginii Info Oltenia 2018 Proba Individuala Clasa a 9-a | Autentificare | Cod sursa (job #2987816) | Cod sursa (job #2365583) | Cod sursa (job #2451288)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("sumdiv.in");
ofstream g ("sumdiv.out");
int mod=9901;
long long abmodc(long long a,long long b, long long c)
{
// a^b mod c
c=mod;
if(a % mod == 0)
return 0;
int res = 1;
while(b)
{
if(b & 1)
res = (res * a) % mod;
b >>= 1;
a = (a * a) % mod;
}
return res;
}
long long inv(long long x)
{
return abmodc(x, mod-2, mod);
}
long long a,b;
int main()
{
f>>a>>b;
if(b==0)
{g<<"1";
return 0;
}
if(a==0)
{
g<<"0";
return 0;
}
if(a==1)
{
g<<1;
return 0;
}
long long p=2;
long long s=1;
long long putere=0;
while(a>1)
{
putere=0;
while(a%p==0)
{
a/=p;
putere+=1;
}
if(putere!=0)
{
if(p%mod==1)
{
s*=(b+1) %mod;
s%=mod;
} else {
putere%=mod;
s *= abmodc(p, putere*b+1, mod) %mod -1;
s%=mod;
s*=inv(p-1);
s%=mod;
}
}
p++;
if(a>1 && p*p>a)
p=a;
}
g<<s;
return 0;
}