Cod sursa(job #2470864)
Utilizator | Data | 9 octombrie 2019 20:23:44 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | basic_stuff | Marime | 0.35 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
unsigned long long n, p, prod = 1;
int main() {
in >> n >> p;
while(p) {
if(p%2 == 1)
prod = (prod*n)%MOD;
n = (n*n)%MOD;
p /= 2;
}
out << prod;
in.close();
out.close();
return 0;
}