Cod sursa(job #2816978)
Utilizator | Data | 12 decembrie 2021 17:26:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
#define mF "lgput"
std::ifstream in(mF ".in");
std::ofstream out(mF ".out");
constexpr int M = 1999999973; using L = long long;
L a; int A(L b)
{
if (b) {L c = A(b >> 1);
return c * c % M * (b & 1? a: 1) % M;}
return 1;
}
int main() {L b; in >> a >> b; out << A(b);}