Cod sursa(job #2831193)
Utilizator | Qwerty Dvorak QwertyDvorak | Data | 10 ianuarie 2022 22:06:45 |
---|---|---|---|
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;
#define pb push_back
using ll = long long;
const string fn = "lgput";
ifstream fin(fn + ".in");
ofstream fout(fn + ".out");
const ll mod = 1999999973;
ll n, p;
ll pwr(ll a, ll n) {
ll ans = 1LL;
while (n) {
if (n & 1)
ans = 1ll * ans * a % mod;
a = 1ll * a * a % mod;
n >>= 1;
}
return ans;
}
int main() {
fin >> n >> p;
fout << pwr(n, p) << '\n';
fin.close();
fout.close();
return 0;
}