Files
python/TangDou/AcWing/NumberTheory/逆元/test.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

21 lines
377 B
C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL qmi(LL a, LL k, LL p) {
LL res = 1;
while (k) {
if (k & 1) res = res * a % p;
k >>= 1;
a = a * a % p;
}
return res;
}
int main() {
int a, p;
cin >> a >> p;
LL x = qmi(a, p - 2, p); // x为a在mod p意义下的逆元
return 0;
}