Cod sursa(job #2345612)
Utilizator | Data | 16 februarie 2019 15:21:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
int R = 1;
const int MOD = 1999999973;
int pow(int num, int expo) {
while(expo != 0) {
if(expo % 2 == 1)
R = (1LL * R * num) % MOD;
num = (1LL * num * num) % MOD;
expo /= 2;
}
return R;
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int a, b;
fin >> a >> b;
fout << pow(a, b);
return 0;
}