Cod sursa(job #2718498)
Utilizator | Data | 8 martie 2021 19:35:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | no-time-to-rest | Marime | 0.28 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream fe("lgput.out");
int main()
{
long long b,e,P=1;
f>>b;
f>>e;
while(e)
{
if(e % 2 == 1)
P=P*b;
b=b*b;
e=e/2;
}
fe<<P;
return 0;
}