Cod sursa(job #2999076)
| Utilizator | Data | 10 martie 2023 14:31:58 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <fstream>
#define lli long long int
#define MOD 1999999973
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
lli fastPower(lli base, lli power) {
lli powerValue = 1;
while (power) {
if (power % 2 == 1)
powerValue = (powerValue * base) % MOD;
base = (base * base) % MOD;
power /= 2;
}
return powerValue;
}
int main() {
lli base, power;
cin >> base >> power;
cout << fastPower(base, power);
}