Cod sursa(job #1734744)
Utilizator | Data | 28 iulie 2016 02:54:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main()
{
long long int sol,powsol,pow,n;
in>>n>>pow;
sol=n;
powsol=1;
while(powsol<pow)
{
if(powsol<=pow/2)
{
sol=sol*sol;
powsol=powsol*2;
}
else
{
sol=sol*n;
powsol++;
}
}
out<<sol;
}