Pagini recente » Cod sursa (job #1214301) | Cod sursa (job #2096844) | Cod sursa (job #2315412) | Cod sursa (job #2481064) | Cod sursa (job #177323)
Cod sursa(job #177323)
#include <stdio.h>
#define M 1999999973
#define impar(x) ((x & 1) == 1)
#define t long long
t exp_log(t b, t e)
{
if(e==0 || e==1) return b % M;
if(impar(e))
{
t rp = exp_log(b, e-1);
return (rp*(b%M))%M;
}
else
{
t rp = exp_log(b, e/2);
return (rp*rp)%M;
}
}
int main()
{
t baza, exponent;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld",&baza,&exponent);
fclose(stdin);
printf("%lld\n",exp_log(baza,exponent));
fclose(stdout);
}