Mai intai trebuie sa te autentifici.
Cod sursa(job #726303)
| Utilizator | Data | 27 martie 2012 09:59:32 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include <cstdio>
using namespace std;
int a,b;
long long pow(int a, int b)
{
long long aux=1;
if (b==1) return a;
else
{
if (b%2==0)
{
aux=aux*pow(a,b/2);
return aux*aux;
}
else return a*pow(a,b-1);
}
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d%d",&a,&b);
printf("%I64d",pow(a,b));
return 0;
}
