Cod sursa(job #1466650)
Utilizator | Data | 29 iulie 2015 19:10:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
#define Mod 1999999973
using namespace std;
int main() {
long long masc, a, b, s;
masc = s = 1;
ifstream f("lgput.in");
f >> a;
f >> b;
while (masc <= b) {
if (b & masc) {
s = (s * a) % Mod;
}
a = (a * a) % Mod;
masc = masc << 1;
}
ofstream g("lgput.out");
g << s;
f.close();
g.close();
return 0;
}