Pagini recente » Profil manuelapostol20 | Cod sursa (job #2207956) | Cod sursa (job #1298680) | Cod sursa (job #1824469) | Cod sursa (job #942756)
Cod sursa(job #942756)
#include<cstdio>
#define mod 9901
using namespace std;
int putere(int q,int exp)
{
int ans;
if(!exp)
return 1;
ans=putere(q,exp/2);
ans=(ans*ans)%9901;
if(exp&1)
ans=(ans*q)%9901;
return ans;
}
int progresie(int q, int exp)
{
if(q==1)
return (exp+1)%mod;
if(exp==1)
return (q+1)%mod;
if(exp==0)
return 1;
if(exp&1)
return (1+((q%mod)*progresie(q,exp-1))%mod)%mod;
int ans=progresie(q,exp/2);
ans=(ans+(putere(q,exp/2)*(ans+9900))%9901)%9901;
return ans;
}
int main()
{
freopen("sumdiv.in","r",stdin);
freopen("sumdiv.out","w",stdout);
int A,B,S,d,p;
scanf("%d %d", &A, &B);
S=0;
for(p=0;!(A&1);++p,A>>=1);
S=progresie(2,p*B);
for(d=3;d*d<=A;d+=2)
if(!(A % d))
{
for(p=0;!(A%d);++p,A/=d);
S=(S*progresie(d%9901,p*B))%9901;
}
if(A>1)
S=(S*progresie(A%9901,B))%9901;
printf("%d\n",S);
return 0;
}