Pagini recente » Cod sursa (job #2212192) | civilizatie | Cod sursa (job #1998112) | Monitorul de evaluare | Cod sursa (job #201641)
Cod sursa(job #201641)
#include <stdio.h>
#include <vector>
using namespace std;
#define modulo 9901
#define pb push_back
#define sz size()
vector<int> v;
int a,b,sol;
int st[20];
int power(int x, int e)
{
if (e==1) return x%modulo;
if (e==0) return 1;
return ( power(x,e/2)*power(x,e-e/2) )%modulo;
}
void compute(int p, int e)
{
e=e*b;
int x,y,z;
x=p%modulo;
y=power(p,e)-1;
if (y<0) y+=modulo;
z=power(p-1,9899);
v.pb( ( (x*y)%modulo )%modulo );
}
void back(int nivel)
{
if (nivel==v.sz)
{
int i,k=1;
for (i=0;i<v.sz;i++)
if (st[i]) k=(k*v[i])%modulo;
sol=(sol+k)%modulo;
return;
}
st[nivel]=0;
back(nivel+1);
st[nivel]=1;
back(nivel+1);
}
int main()
{
freopen("sumdiv.in","r",stdin);
freopen("sumdiv.out","w",stdout);
int i,p,e;
scanf("%d %d",&a,&b);
for (i=2;i*i<=a;i++)
{
if (a%i) continue;
p=i;
for (e=0;a%p==0;e++,a/=p);
compute(p,e);
}
if (a>1) compute(a,1);
back(0);
printf("%d",sol);
return 0;
}