Cod sursa(job #2761835)
Utilizator | Data | 4 iulie 2021 12:16:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main()
{
int x, p, c=0;
cin>>x>>p;
if(p%2==1)
c=x;
x*=x;
p/=2;
while(p>1)
{
x*=x;
p/=2;
}
if(c>0)
x*=c;
cout<<x;
return 0;
}