Pagini recente » Cod sursa (job #2060820) | Monitorul de evaluare | Cod sursa (job #1038071) | Cod sursa (job #1520364) | Cod sursa (job #2931814)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long logh_exp(long long N,long long P){
if(P<0)
return logh_exp(1/N,-P);
if(P == 0)
return 1;
if(P % 2 == 0 ){
return logh_exp(N*N,P/2);
}
else
return N*logh_exp(N*N,(P-1)/2);
}
int main()
{
long long N,P;
fin>>N>>P;
fout<<logh_exp(N,P);
return 0;
}