Pagini recente » Cod sursa (job #1996281) | Cod sursa (job #374221) | Cod sursa (job #1288742) | template/preoni-2007/footer | Cod sursa (job #2931824)
#include <iostream>
#include <fstream>
#define Nr 1999999973
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)%Nr,P/2);
}
else
return N*logh_exp((N*N)%Nr,(P-1)/2);
}
int main()
{
long long N,P;
fin>>N>>P;
fout<<logh_exp(N,P);
return 0;
}