Cod sursa(job #2491026)
Utilizator | Data | 11 noiembrie 2019 17:51:55 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.24 kb |
#include <iostream>
using namespace std;
int pow(int x, int n) {
if (!n)
return 1;
if (n % 2)
return x * pow(x * x, n / 2);
return pow(x * x, n / 2);
}
int main(){
int a,b;
cin>>a>>b;
cout<<pow(a,b);
}