Pagini recente » Cod sursa (job #215254) | Cod sursa (job #2641550) | Cod sursa (job #2673164) | Cod sursa (job #2724998) | Cod sursa (job #177308)
Cod sursa(job #177308)
#include <stdio.h>
#define M 1999999973
#define par(x) ((x & 1) == 0)
int rez_part[10000];
int exp_log(int b, int e)
{
if(rez_part[e]) return rez_part[e];
if(par(e))
{
rez_part[e] = (exp_log(b,e/2) * exp_log(b,e/2)) % M;
return rez_part[e];
}
else
{
rez_part[e] = (b * exp_log(b,e-1)) % M;
return rez_part[e];
}
}
int main()
{
int baza, exponent;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d %d",&baza,&exponent);
fclose(stdin);
rez_part[1] = baza;
printf("%d\n",exp_log(baza,exponent));
fclose(stdout);
}