Pagini recente » Cod sursa (job #2189172) | Cod sursa (job #1616342) | Cod sursa (job #2825601) | Cod sursa (job #1581509) | Cod sursa (job #523653)
Cod sursa(job #523653)
#include <fstream>
using namespace std;
ifstream fin("sumdiv.in");
ofstream fout("sumdiv.out");
const int M=9901;
int i,A,B;
long long S=1;
void euclid(int a, int b, int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
}
else
{
int x0,y0;
euclid(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int put(int c, int p)
{
long long R=1;
while(p>0)
{
if(p&1) { R=R*c; R%=M; }
c=c*c;
c%=M;
p>>=1;
}
return R;
}
void rez()
{
int p,p1,p2; //int x,y;
for(i=2;i*i<=A;i++)
{
if(A%i>0) continue;
p=0;
while(A%i==0)
{
A/=i;
p++;
}
if(i%M==1) S*=1LL*(p+1) % M;
else
{
p1= ( put(i,p*B+1) - 1) + M;
p1%=M;
//euclid(i-1,M,x,y);
//while(x<0) x+=M;
//p2=x % M;
p2= put(i-1,M-2) % M;
S=S* 1LL * (p1 * p2);
S%=M;
}
}
if(A>1)
{
if(A % M == 1 )
S=(S* 1LL * (B % M + 1)) % M;
else
{
p1= ( put(A,B+1) - 1) + M;
p1%=M;
//euclid(A-1,M,x,y);
//while(x<0) x+=M;
//p2=x % M;
p2=put(A-1,M-2) % M;
S=(S* 1LL * (p1 * p2));
S%=M;
}
}
}
int main()
{
fin >> A >> B;
rez();
if(A==0) fout << "0";
else fout << S;
}
/*#include <cstdio>
const int mod = 9901;
using namespace std;
int A, B, rez, nr;
inline int putere(int N, int exp) {
if (exp == 0) return 1;
if (exp == 1) return N % mod;
if (exp % 2 == 0) {
int aux = putere(N % mod, exp / 2);
return (aux * aux % mod);
}
else {
return (putere(N % mod, exp - 1) * N % mod);
}
}
int main() {
int i;
freopen("sumdiv.in", "r", stdin);
freopen("sumdiv.out", "w", stdout);
scanf("%d%d", &A, &B);
if (A == 1) {
printf("1\n");
return 0;
}
rez = 1;
for (i = 2; i * i <= A; i++) if (A % i == 0) {
nr++;
int exp = 0;
while (A % i == 0) {
A /= i;
exp++;
}
exp *= B;
if (i % mod == 1)
rez = rez * (exp + 1) % mod;
else
{
rez = rez * (putere(i, exp + 1) + mod - 1) % mod * putere(i - 1, mod - 2) % mod;
int test= (putere(i, exp + 1) + mod - 1) % mod;
int test2= putere(i - 1, mod - 2) % mod;
}
}
if (A != 1) {
if (A % mod > 1)
rez = (rez * ((putere(A, B + 1) + mod - 1) % mod)) % mod * putere(A % mod - 1, mod - 2) % mod;
else
if (A % mod == 1)
rez = rez * (B % mod + 1) % mod;
}
printf("%d\n", rez % mod);
return 0;
}*/