Cod sursa(job #3039001)
| Utilizator | Data | 27 martie 2023 23:34:44 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <iostream>
using namespace std;
const long long mod = 1999999973;
long long fastExp(long long base, long long exp) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) {
res = (res * base) % mod;
}
base = (base * base) % mod;
exp /= 2;
}
return res;
}
int main() {
ofstream cout("lgput.out");
ifstream cin("lgput.in");
long long n, p;
cin >> n >> p;
long long ans = fastExp(n, p);
cout << ans << endl;
return 0;
}
