You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
377 B

#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;
}