Cod sursa(job #3161864)
Utilizator | Data | 28 octombrie 2023 09:43:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main(){
long long a, b;
fin >> a >> b;
a = a % MOD;
int p = 1;
while(b){
if(b%2==1)
p = (p*a)%MOD;
b /= 2;
a = (a*a)%MOD;
}
fout << p;
fin.close();
fout.close();
}