Pagini recente » Cod sursa (job #2280338) | Cod sursa (job #2325532) | Cod sursa (job #2857927) | Cod sursa (job #2854761) | Cod sursa (job #2384639)
#include <bits/stdc++.h>
using namespace std;
int baze[50],puteri[50],cnt=0;
long long a,b,sol=1;
void invmod(int &x,int &y,int a,int b)
{ if (!b) x = 1, y = 0;
else
{ invmod(x, y, b, a % b);
int aux = x;
x = y;
y = aux - y * (a / b);
}
}
long long Rlog2(int b,int p)
{ long long r=1;
while(p)
{ if(p&1) r*=b;
b*=b;
p>>=1;
}
return r;
}
void afis()
{ ofstream g ( "sumdiv.out" );
g<<sol;
}
void citire()
{ ifstream f ( "sumdiv.in" );
f>>a>>b;
}
void desc(int n)
{ for(int d=2;d*d<=n;d++)
{ if(n%d==0)
{ int e=0;
while(n%d==0)
{ n/=d;
e++;
}
cnt++;
baze[cnt]=d; puteri[cnt]=e;
}
}
if(n>1) baze[++cnt]=n,puteri[cnt]=1;
}
void rezolva()
{ for(int i=1;i<=cnt;i++)
{ int w=Rlog2(baze[i],(puteri[i]*b+1));
w--;
sol=sol*w%9901;
}
for(int i=1;i<=cnt;i++)
{ int cx,cy,a,b;
invmod(cx,cy,( baze[i]-1),9901);
if(cx<=0) cx=9901+cx%9901;
sol=sol*cx%9901;
}
}
int main()
{ citire();
desc(a);
rezolva();
afis();
return 0;
}