Cod sursa(job #2845568)
| Utilizator | Data | 7 februarie 2022 23:03:03 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
#ifdef LOCAL
ifstream f("input.txt");
#define g cout
#else
ifstream f("lgput.in");
ofstream g("lgput.out");
#endif
const int MOD = 1999999973;
uint32_t x, y;
int pow2(int x, int y) {
if (y == 0)
return 1;
else if (y % 2 == 0)
return pow2((1LL * x * x) % MOD, y / 2);
else
return 1LL * x * pow2(x * x, (y-1) / 2) % MOD;
}
int main() {
f >> x >> y;
g << pow2(x, y);
}
