Pagini recente » Cod sursa (job #965902) | Cod sursa (job #2630781) | Cod sursa (job #2652768) | Cod sursa (job #3133817) | Cod sursa (job #2232319)
#include <fstream>
const std::string programName = "lgput";
std::ifstream f(programName + ".in");
std::ofstream g(programName + ".out");
const int constant = 1999999973;
int main() {
int N, P;
f >> N >> P;
int16_t Xcopy, sol = 1;
Xcopy = N;
for (int i = 0; (1 << i) <= P; ++i) {
if ( ((1 << i) & P) > 0)
sol = (sol * Xcopy) % constant;
Xcopy = (Xcopy * Xcopy) % constant;
}
g << sol;
return 0x0;
}