Modular inverse
Your task
Given a prime p and a list of integers, return the modular inverse of each element modulo p, i.e. for each x return the y in [0, p-1] with (x*y) % p == 1. Every input element is guaranteed coprime to p (1 <= x < p). Use Fermat's little theorem. Constraints: p is an odd prime up to 10^9+7, list length up to 1000.
Examples
mod_inverses(p: int, xs: list[int]) -> list[int]Example 1
Input
mod_inverses(7, [1, 2, 3])Output
[1, 4, 5]