Cod sursa(job #2148243)
Utilizator | Data | 1 martie 2018 16:43:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
long long n, p, putere, sol = 1;
int main () {
ifstream fi("lgput.in");
ofstream fo("lgput.out");
fi >> n >> p;
for (; p > 0; p >>= 1) {
if (p & 1)
sol = sol*n % 1999999973;
n = n*n % 1999999973;
}
fo << sol;
return 0;
}