Cod sursa(job #156495)
| Utilizator | Data | 12 martie 2008 16:33:48 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <stdio.h>
#define modulo 1999999973
long long n, p;
long long pow(long long x, long long y)
{
long long aux;
if (y == 0)
return 1;
if (y & 1)
return ((x * pow(x, y-1)) % modulo);
else
aux = (pow(x, y/2) % modulo);
return ((aux*aux) % modulo);
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out","w",stdout);
scanf("%lld %lld ", &n, &p);
printf("%lld\n", pow(n, p) % modulo);
return 0;
}
