Pagini recente » Cod sursa (job #1173505) | Cod sursa (job #2676003) | Cod sursa (job #1807490) | Cod sursa (job #217015) | Cod sursa (job #1260077)
#include<stdio.h>
#include<math.h>
#define LL long long
const int MOD = 9901, NMAX = 30;
int nfact, f[NMAX];
LL p[NMAX];
int lgPow (int x, LL expo) {
if(expo == 0)
return 1;
if(expo & 1)
return (x * lgPow(x, expo - 1)) % MOD;
int half = lgPow(x, expo / 2);
return (half * half) % MOD;
}
void fact (int n) {
int d, lim, e;
lim = sqrt(n);
d = 2;
while(n > 1 && d <= lim) {
e = 0;
while(n % d == 0)
++ e,
n /= d;
if(e) {
++ nfact;
f[nfact] = d % MOD;
p[nfact] = e;
}
++ d;
}
if(n > 1) {
++ nfact;
f[nfact] = n % MOD;
p[nfact] = 1;
}
}
int invMod (int x) {
return lgPow(x, MOD - 2);
}
int main() {
freopen("sumdiv.in", "r", stdin);
freopen("sumdiv.out", "w", stdout);
int i, a, b, res;
scanf("%d%d", &a, &b);
if(b == 0) {
printf("1\n");
return 0;
}
fact(a);
for(i = 1; i <= nfact; ++ i)
p[i] *= (LL)b;
res = 1;
for(i = 1; i <= nfact; ++ i) {
res = (res * ((lgPow(f[i], p[i] + 1) - 1) % MOD)) % MOD;
res = (res * invMod(f[i] - 1)) % MOD;
}
printf("%d\n", res);
return 0;
}