Cod sursa(job #981176)
Utilizator | Data | 6 august 2013 15:27:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <stdio.h>
#define DIVIDER 1999999973
long pow1(unsigned a, unsigned b)
{
long exp = a;
int i;
for (i = 0; i <= b; ++i)
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;
}