SHARE
TWEET

Untitled

a guest Mar 24th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2.  
  3. def egcd(a, b):
  4.     if a == 0:
  5.         return (b, 0, 1)
  6.     else:
  7.         g, x, y = egcd(b % a, a)
  8.         return (g, y - (b // a) * x, x)
  9.  
  10. def mulinv(b, n):
  11.     g, x,_= egcd(b, n)
  12.     if g == 1:
  13.         return x%n
  14.     else:
  15.         return -1
  16.  
  17. n,a=map(int,input().split())
  18. print(mulinv(a,n))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top