Cod sursa(job #981187)
| Utilizator | Data | 6 august 2013 15:35:45 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | c | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <stdio.h>
#define DIVIDER 1999999973
long pow1(unsigned a, unsigned b)
{
long exp = a;
int i;
for (i = 1; i <= b; ++i)
exp = (exp * a) % DIVIDER;
return exp;
}
int main()
{
unsigned N, P;
unsigned i;
long long exp = 1;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d %d", &N, &P);
for (i = 1; i <= P; ++i)
exp = (exp * N) % DIVIDER;
printf("%lld\n", exp);
return 0;
}
