Cod sursa(job #3259794)
| Utilizator | Data | 27 noiembrie 2024 20:32:12 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1999999973;
long long expPow(long long x, long long y) {
if (y == 0) {
return 1;
}
if (y % 2) {
return (x * expPow((x * x) % MOD, y / 2)) % MOD;
}
return expPow((x * x) % MOD, y / 2);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
long long x, y;
cin >> x >> y;
cout << expPow(x, y);
return 0;
}
