Cod sursa(job #2811173)
Utilizator | Data | 1 decembrie 2021 13:53:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int main() {
long long a, b;
fin >> a >> b;
long long p = 1;
while (b) {
if (b % 2 == 1) {
p = (p * a) % MOD;
}
a = (a * a) % MOD;
b /= 2;
}
fout << p;
return 0;
}