Cod sursa(job #2637632)
Utilizator | Data | 23 iulie 2020 19:20:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int mod = 1999999973;
int main() {
int n, i = 1, p, x = 1;
in >> n >> p;
int v = n;
while (i <= p) {
if (p & i)
x = (1ll * x * v) % mod;
v = (1ll * v * v) % mod;
i <<= 1;
}
out << x;
return 0;
}