We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1d03a1 commit 25b2867Copy full SHA for 25b2867
day13.py
@@ -1,15 +1,6 @@
1
def modular_multiplicative_inverse(a: int, m: int) -> int:
2
- # ref: https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
3
- if m == 1:
4
- return 0
5
-
6
- m0, y, x = m, 0, 1
7
- while a > 1:
8
- q = a // m
9
- a, m = m, a % m
10
- x, y = y, x - q * y
11
12
- return x + m0 if x < 0 else x
+ # ref: https://docs.python.org/3/whatsnew/3.8.html
+ return pow(a, -1, m)
13
14
15
def chinese_remainder_theorem_solver(divisors_and_remainders: list) -> int:
0 commit comments