Cod sursa(job #3039002)
| Utilizator | Data | 27 martie 2023 23:35:03 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.54 kb |
#include <bits/stdc++.h>
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;
}
