4185 费马小定理求逆元
⭐️难度:简单
🌟考点:费马小定理
📖
📚
import java.util.Scanner;
import java.util.Arrays;public class Main {static int[][] a;public static void main(String[] args) {Scanner sc = new Scanner(System.in);long a = sc.nextInt();long p = sc.nextInt();long inverse = qmod(a,p-2,p);System.out.println(inverse);}static long qmod(long a, long b,long p){long res = 1;while(b != 0){if((b&1) == 1){res = res * a % p;}a = a * a % p;b >>= 1;}return res;}
}