Mai intai trebuie sa te autentifici.
Cod sursa(job #3211059)
| Utilizator | Data | 8 martie 2024 12:08:14 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
using namespace std;
int lgput(int x, int n)
{
if (n == 0) return 1;
if (n % 2 == 0)
{
return x * lgput(x,((n-1)/2)) * lgput(x,((n-1)/2));
}
else
{
return lgput(x,((n-1)/2)) * lgput(x,((n-1)/2));
}
}
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int x, y;
fin >> x >> y;
fout << lgput(x,y);
return 0;
}
