SHARE
TWEET

Untitled

a guest Jan 25th, 2020 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a,b = map(int,input().split())
  2. c = 1
  3. from math import gcd
  4. g = gcd(a,b)
  5. if c % g != 0:
  6.     print('-1')
  7. else:
  8.     a//=g; b//=g; c//=g
  9.     mas = [[1,0,a],[0,1,b]]
  10.     while True:
  11.         if mas[0][2] == 1:
  12.             x = mas[0][0]
  13.             y = mas[0][1]
  14.             break
  15.         elif mas[1][2] == 1:
  16.             x = mas[1][0]
  17.             y = mas[1][1]
  18.             break  
  19.         if mas[0][2] > mas[1][2]:
  20.             pass
  21.         else:
  22.             mas1 = mas[0]
  23.             mas2 = mas[1]
  24.             mas = [mas2,mas1]
  25.         qw = mas[0][2] // mas[1][2]
  26.         mas1 = [mas[0][0]-mas[1][0]*qw,mas[0][1]-mas[1][1]*qw,mas[0][2] - mas[1][2] * qw]
  27.         mas.pop(0)
  28.         mas.append(mas1)
  29.     print((x*c)%b)
  30.     if (((x*c)%b) * a) % b == 1:
  31.         print('Ты тролль')
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
Top