Cod sursa(job #2998353)
| Utilizator | Data | 9 martie 2023 12:33:20 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.36 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int a , b;
int alab (int a , int b)
{
if (b == 0)
return 1;
int p = alab (a , b / 2);
if (b % 2 == 1)
return p * p * a;
else
return p * p;
}
int main()
{
f >> a >> b;
g << alab (a , b);
return 0;
}
