Cod sursa(job #883265)
Utilizator | Data | 19 februarie 2013 21:20:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<fstream>
#include<iostream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long m, n, a = 1;
long long c = 1999999973;
int main() {
fin >> m >> n;
while(n != 0) {
if(n % 2) {
a *= m;
}
m *= m;
n /= 2;
}
fout << a % c;
fin.close();
fout.close();
return 0;
}