Cod sursa(job #2669282)
Utilizator | Data | 6 noiembrie 2020 17:45:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
typedef long long ll;
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll pow(ll a, ll b)
{
if(b == 1)
return a;
if(b & 1)
return a * pow(a, b - 1);
else
{
ll x = pow(a, b / 2);
return x * x;
}
}
int main()
{
ll a,b;
f >> a >> b;
g << pow(a,b);
}