Cod sursa(job #1016722)
Utilizator | Data | 26 octombrie 2013 17:34:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <cstdio>
#define kk unsigned long long
using namespace std;
kk x;
kk gyors(kk a,kk k)
{
if(k==1) return a;
else x=gyors(a,k/2);
x=x*x;
if(k%2==1)
{
x=x*a;
}
return x;
}
int main()
{freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
kk a,k;
scanf("%llu%llu",&a,&k);
printf("%llu",gyors(a,k));
return 0;
}