Pagini recente » Monitorul de evaluare | Cod sursa (job #2820371) | Diferente pentru problema/paralelogram2 intre reviziile 32 si 33 | Cod sursa (job #1179777) | 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;
}