Cod sursa(job #2860317)
Utilizator | Cuibus Dorin Iosif Dorin07 | Data | 2 martie 2022 12:53:17 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#define MODULO 1999999973
typedef long long ll;
using namespace std;
ll a, b;
ll log_power(ll base, ll power){
ll result = 1;
while(power > 0){
if(power & 1){
result = (result * base) % MODULO;
--power;
}
base = (base * base) % MODULO;
power >>= 1;
}
return result;
}
void read(){
cin >> a >> b;
cout << log_power(a, b);
}
int main()
{
read();
return 0;
}