Cod sursa(job #2860319)
Utilizator | Data | 2 martie 2022 12:55:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.58 kb |
#include <fstream>
#define MODULO 1999999973
typedef long long ll;
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
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(){
f >> a >> b;
g << log_power(a, b);
f.close();
g.close();
}
int main()
{
read();
return 0;
}