Cod sursa(job #1925429)
Utilizator | Data | 13 martie 2017 10:23:39 | |
---|---|---|---|
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;
int main () {
ifstream fi("lgput.in");
ofstream fo("lgput.out");
fi >> n >> p;
for (putere = n, sol = 1; p > 0; p >>= 1) {
if (p & 1)
sol = sol*putere % 1999999973;
putere = putere*putere % 1999999973;
}
fo << sol;
return 0;
}