Cod sursa(job #2485472)
Utilizator | Data | 1 noiembrie 2019 17:20:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
using namespace std;
const int MOD = 1999999973;
long long put_log(long long n, long long 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");
long long x, y;
fin >> x >> y;
fout << put_log(x, y);
}