Pagini recente » Cod sursa (job #2386294) | Cod sursa (job #2896657) | Cod sursa (job #3248628) | Cod sursa (job #1247813) | Cod sursa (job #1518231)
#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;
N = N * N % DIVISOR;
P = (P-1)/2;
}
}
return N*Y % DIVISOR;
}
int main(){
long long N,P;
in >> N >> P;
out << LgPut(N,P) << "\n";
return 0;
}