Pagini recente » Cod sursa (job #2753557) | Cod sursa (job #828678) | Cod sursa (job #2408929) | Cod sursa (job #435817) | Cod sursa (job #756546)
Cod sursa(job #756546)
#include <fstream>
#define M 9901
#define LL long long
using namespace std;
ifstream f("sumdiv.in");
ofstream g("sumdiv.out");
LL A,B,T1=1,T2=1,i,d,x,y;
LL LgPow (LL b, LL p)
{
LL R,X,i;
for (i=1,R=1,X=b;i<=p;i<<=1)
{
if (i&p) R=R*X%M;
X=X*X%M;
}
return R%M;
}
void Div (LL i)
{
d=0;
T2=T2*(i-1+M)%M;
while (A%i==0 && A>1)
{
A/=i;
d++;
}
T1=T1*(LgPow(i,d*B+1)-1+M)%M;
T1=T1*(LgPow(i-1,M-2))%M;
}
void IM (LL &x, LL &y, LL a, LL b)
{
if (!b)
{
x=1;
y=0;
}
else
{
IM(x,y,b,a%b);
LL aux=x;
x=y;
y=aux-y*(a/b);
}
}
int main()
{
f >> A >> B;
for (i=2;i*i<=A && A>1;i++)
if (A%i==0)
Div(i);
if (A>1) Div(A);
x=y=0;
IM(x,y,T2,M);
if (x<=0) x=M+x%M;
//T1=T1*T2%M;
g << T1 << '\n';
f.close();g.close();
return 0;
}