Cod sursa(job #3139089)
Utilizator | Data | 24 iunie 2023 20:11:57 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p;
fin >> n >> p;
long long buf = 1;
while (p > 0) {
if(p % 2 == 1) {
buf = (buf * n) % 1999999973;
}
n = (n * n) % 1999999973;
p /= 2;
}
fout << buf << std::endl;
fin.close();
fout.close();
return 0;
}