Cod sursa(job #1647157)
Utilizator | Data | 10 martie 2016 19:11:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long putere(int x, int n)
{
while(n > 0)
{
x *= x;
n--;
}
}
int main()
{
int x, n;
f >> x;
f >> n;
g << putere(x, n);
f.close();
g.close();
return 0;
}