Pagini recente » Cod sursa (job #161849) | Cod sursa (job #134472) | Clasament dupa rating | Cod sursa (job #2017879) | Cod sursa (job #177316)
Cod sursa(job #177316)
#include <stdio.h>
#define M 1999999973
#define par(x) ((x & 1) == 0)
int exp_log(int b, int e)
{
if(e==0 || e==1) return b % M;
if(par(e))
{
long rp = exp_log(b, e-1);
return (rp*(b%M))%M;
}
else
{
long rp = exp_log(b, e/2);
return (rp*rp)%M;
}
}
int main()
{
int baza, exponent;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d %d",&baza,&exponent);
fclose(stdin);
printf("%d\n",exp_log(baza,exponent));
fclose(stdout);
}