Cod sursa(job #3189031)
Utilizator | Data | 4 ianuarie 2024 13:31:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define CONST 1999999973
int main() {
int a, b, p=1;
fin>>a>>b;
while (b!=0) {
if (b%2==1) p=(p*a)%CONST;
a=((a%CONST)*(a%CONST))%CONST;
b/=2;
}
fout<<p%CONST;
fin.close();
fout.close();
return 0;
}