Pagini recente » Cod sursa (job #1136115) | Cod sursa (job #768237) | Cod sursa (job #621233) | Cod sursa (job #3140210) | Cod sursa (job #2232329)
#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;
int64_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;
}