Cod sursa(job #1113567)
Utilizator | Data | 20 februarie 2014 18:23:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.52 kb |
#include <fstream>
using namespace std;
int main() {
ifstream in("lgput.in");
ofstream out("lgput.out");
int x,y;
long long int z,p;
in >> x >> y;
z = 1;
p = x;
while( y != 0) {
if(y%2 != 0){
z *= p;
z %= 1999999973;
}
p = p*p;
p %= 1999999973;
y /= 2;
}
out << z;
in.close();
out.close();
}