Cod sursa(job #1118797)
Utilizator | Data | 24 februarie 2014 13:17:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <cstdio>
using namespace std;
unsigned long long int x;
unsigned long long int gyors(int a,int 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);
unsigned long long int n,m;
scanf("%llu%llu",&n,&m);
printf("%llu",gyors(n,m));
}