Cod sursa(job #2370521)
Utilizator | Data | 6 martie 2019 12:30:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <stdio.h>
using namespace std;
long long a,b;
long long putere(long long a,long long b){
if(b==0) return 1;
long long x=putere(a,b/2);
if(b%2==1) return x*x*a;
else return x*x;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&a,&b);
printf("%lld\n",putere(a,b));
return 0;
}