Pagini recente » Cod sursa (job #313703) | Cod sursa (job #2824429) | Cod sursa (job #505247) | Cod sursa (job #2642490) | Cod sursa (job #1518221)
#include <stdio.h>
#include <fstream>
#define DIVISOR 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long LgPut(long long N, long long P){
if(P == 0) return 1;
if(P == 1) return N;
long long Y = 1;
while(P > 1){
if(P % 2 == 0){
N = N * N % DIVISOR;
P /= 2;
}
else{
Y = Y * N % DIVISOR;
P = P-1;
}
}
return N*Y % DIVISOR;
}
int main(){
long long N,P;
in >> N >> P;
out << LgPut(N,P) << "\n";
return 0;
}