Cod sursa(job #613894)
Utilizator | Data | 4 octombrie 2011 23:55:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <cstdio>
long long pow(int a, int b)
{
if ( !b ) return 1;
return ( b%2 == 0 ) ? pow( (long long)a*a, b/2 ) : a*pow( (long long)a*a, b/2);
}
int main()
{
int x, y;
long long r;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d%d", &x, &y);
r = pow(x, y);
printf("%lld", r%31720000L);
}