Pagini recente » Cod sursa (job #1565313) | Cod sursa (job #713982) | Cod sursa (job #1264145) | Cod sursa (job #1915280) | Cod sursa (job #177318)
Cod sursa(job #177318)
#include <stdio.h>
#define M 1999999973
#define impar(x) ((x & 1) == 1)
int exp_log(int b, int e)
{
if(e==0 || e==1) return b % M;
if(impar(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);
}