Pagini recente » Cod sursa (job #66529) | Cod sursa (job #1999523) | Cod sursa (job #285942) | Cod sursa (job #1263832) | Cod sursa (job #1161696)
#include<stdio.h>
#include<algorithm>
#include<vector>
#define pb push_back
#define MOD 9901
#define lim 10100
using namespace std;
int A,B,sol=1;
int sieve[lim+5];
vector<int> l;
void read()
{
scanf("%d%d",&A,&B);
}
void preproc()
{
for(int i=2;1LL*i*i<=lim;i++)
if(!sieve[i*i])
for(int j=i;1LL*i*j<=lim;j++)
sieve[i*j]=1;
for(int i=2;i<=lim;i++)
if(!sieve[i]) l.pb(i);
}
void gcd(int a,int b,long long &x,long long &y)
{
if(b==0) {x=1; y=0; return;}
long long x0,y0;
gcd(b,a%b,x0,y0);
x=y0;
y=x0-1LL*(a/b)*y0; while(y<0) y+=MOD;
y%=MOD;
}
void update(int f)
{
int nr,p,add;
long long x,y;
for(nr=0;A%f==0;A/=f,nr++);
nr*=B; nr++; p=1; add=f;
if((f-1)%MOD==0) {sol=(1LL*sol*(nr%MOD))%MOD; return;}
for(int j=0;(nr>>j);j++)
{
if( ((nr>>j)&1) ) p=(1LL*p*add)%MOD;
add=(1LL*add*add)%MOD;
}
p--; if(p<0) p+=MOD; printf("%d ",p);
gcd(f-1,MOD,x,y);
while(x<0) x+=MOD;
p=(1LL*p*x)%MOD;
sol=(1LL*sol*p)%MOD;
}
void solve()
{
for(unsigned int i=0;i<l.size() && 1LL*l[i]*l[i]<=A;i++)
if(A%l[i]==0) update(l[i]);
if(A>1) update(A);
}
int main()
{
freopen("sumdiv.in","r",stdin);
freopen("sumdiv.out","w",stdout);
read();
preproc();
solve();
printf("%d",sol);
fclose(stdin);
fclose(stdout);
return 0;
}