Cod sursa(job #981172)
Utilizator | Data | 6 august 2013 15:25:50 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <stdio.h>
#define DIVIDER 1999999973
long pow1(unsigned a, unsigned b)
{
long exp = a;
while (--b)
exp = exp * a % DIVIDER;
return exp;
}
int main()
{
unsigned N, P;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%ud %ud", &N, &P);
printf("%ld", pow1(N, P));
return 0;
}