Pagini recente » Cod sursa (job #2599111) | Cod sursa (job #1643283) | Cod sursa (job #2266692) | Cod sursa (job #1235194) | Cod sursa (job #2740859)
#include <iostream>
#include <fstream>
unsigned long long RidicareLogaritmica(unsigned long N, unsigned long P) {
if (N == 2)
return (1LL * 1 << P) % 1999999973;
unsigned long long cpy = N;
unsigned long ret = 1;
while (P != 0) {
if ((P & 1) == 1)
ret = (ret * cpy) % 1999999973;
cpy = (cpy * cpy) % 1999999973;
P /= 2;
}
return ret;
}
int main() {
std::ifstream fin("lgput.in");
std::ofstream fout("lgput.out");
unsigned long N, P;
fin >> N >> P;
fout << RidicareLogaritmica(N, P) << '\n';
fin.close();
fout.close();
return 0;
}