Cod sursa(job #628315)
| Utilizator | Data | 1 noiembrie 2011 03:34:04 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include <cstdio>
#define X 1999999973
long long pow(long long a, long long b)
{
if ( b == 0 ) return 1;
if ( b%2 == 0 )
return pow(a*a%X, b/2);
else
return a*pow(a*a%X, b/2)%X;
}
int main()
{
long long x, y, z;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld%lld", &x, &y);
z = pow(x, y);
printf("%lld", z);
}