Cod sursa(job #2485471)
Utilizator | Pricop Laurentiu Laurcons | Data | 1 noiembrie 2019 17:18:36 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
using namespace std;
const int MOD = 1999999973;
int put_log(int n, int p) {
int r = 1;
while (p > 0) {
if (p & 1) {
r = (r * (n % MOD))%MOD;
}
n = (n * n)%MOD;
p>>=1;
}
return r;
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int x, y;
fin >> x >> y;
fout << put_log(x, y);
}