Cod sursa(job #1258467)
Utilizator | Data | 8 noiembrie 2014 22:08:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include<cstdio>
using namespace std;
long long rez(long long x, long long y) {
if(y == 0)
return 1;
long long d = rez(x, y/2);
if(y%2 == 0)
return d*d;
else
return d*d*x;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long a,b;
scanf("%lld%lld",&a,&b);
printf("%lld",rez(a,b));
return 0;
}