Cod sursa(job #729800)
Utilizator | Data | 30 martie 2012 09:54:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
unsigned long long int n,e;
scanf("%lld %lld",&n,&e);
unsigned long long int p=1;
while(e>1)
{
if(e%2==0)
{
n=n*n;
e/=2;
}
else
{
p*=n;
--e;
}
}
n*=p;
printf("Rezultat: %lld",n);
return 0;
}