Pagini recente » Cod sursa (job #2583031) | Cod sursa (job #1789639) | Cod sursa (job #1069834) | Cod sursa (job #1020896) | Cod sursa (job #2931050)
#include <iostream>
#include <fstream>
using namespace std;
#define Nr 9901
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 putere(int a, int n) {
a=a%Nr;
int rez=1;
while(n>0) {
if(n%2==1) {
rez=(rez*a)%Nr;
}
a=(a*a)%Nr;
n=n/2;
}
return rez;
}
int main() {
ifstream in("sumdiv.in");
ofstream out("sumdiv.out");
int a, b, exp=0, d, s=1, x, y, rez, cd;
in>>a>>b;
if(a==0) {
out<<0;
} else {
d=2;
while(d*d<=a) {
while(a%d==0) {
a=a/d;
exp++;
}
if(exp>0) {
exp=exp*b+1;
rez=putere(d, exp)-1;
if(rez<0)
rez+=Nr;
euclid(d-1, Nr, x, y);
if(x<0)
x+=Nr;
s=(s*(rez*x)%Nr)%Nr;
}
exp=0;
d++;
}
if(a>1) {
exp=b+1;
rez=putere(a, exp)-1;
if(rez<0)
rez+=Nr;
euclid(a-1, Nr, x, y);
if(x<0)
x+=Nr;
s=(s*(rez*x)%Nr)%Nr;
}
out<<s;
}
return 0;
}