Cod sursa(job #2345603)
Utilizator | Data | 16 februarie 2019 15:19:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 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 = ((long long)(R * num)) % MOD;
num *= num;
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;
}