Cod sursa(job #2385225)
Utilizator | Data | 21 martie 2019 18:46:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main()
{
int n,p,x,y,z,i;
in>>n>>p;
x=n*n;
z=p/2-1;
y=x;
for(i=1;i<=z;i++)
y*=x;
if(p&1)
y*=n;
out<<y;
return 0;
}