Cod sursa(job #2371335)
Utilizator | Data | 6 martie 2019 17:14:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
ll pow(ll base, ll exp){
ll sol = 1;
for(; exp; exp>>=1, base*=base){
sol*=((exp&1)?base:1);
}
return sol;
}
int main() {
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
ll a, b;
cin >> a >> b;
cout << pow(a, b);
return 0;
}