Cod sursa(job #2491029)
Utilizator | Data | 11 noiembrie 2019 17:56:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long 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(){
ifstream f("lgput.in");
ofstream g("lgput.out");
int a,b;
f>>a>>b;
f.close();
g<<pow(a,b);
g.close();
return 0;
}