Pagini recente » Cod sursa (job #2195287) | Cod sursa (job #550307) | Cod sursa (job #909310) | Cod sursa (job #646453) | Cod sursa (job #756610)
Cod sursa(job #756610)
#include <fstream>
#define M 9901LL
#define LL long long
using namespace std;
ifstream f("sumdiv.in");
ofstream g("sumdiv.out");
LL A,B,T1=1LL,i,d;
LL LgPow (LL b, LL p)
{
LL R,X,i;
b%=M;
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;
while (A%i==0 && A>1)
{
A/=i;
d++;
}
if (i%M==1) {
T1=T1*(d*B+1LL)%M;
return;
}
T1=T1*(LgPow(i,d*B+1LL)-1+M)%M;
T1=T1*(LgPow(i-1LL,M-2LL))%M;
}
int main()
{
f >> A >> B;
if (A==0 || B==0)
{
if (B==0) g << 1 << '\n';
else g << 0 << '\n';
f.close();g.close();
return 0;
}
for (i=2;i*i<=A;i++)
if (A%i==0)
Div(i);
if (A>1) Div(A);
g << T1 << '\n';
f.close();g.close();
return 0;
}