mfgnik

Untitled

Jun 7th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. def gcd_ext(first_num, second_num):
  2. if second_num == 0:
  3. return first_num, 1, 0
  4. d, x, y = gcd_ext(second_num, first_num % second_num)
  5. x, y = y, x - (first_num // second_num) * y
  6. return d, x, y
  7.  
  8.  
  9. a, b, c = map(int, input().split())
  10. d, x, y = gcd_ext(a, b)
  11. if c % d != 0:
  12. print(-1)
  13. else:
  14. a, b, c = map(lambda number: number // d, (a, b, c))
  15. x *= c
  16. y *= c
  17. change = x // b
  18. x -= change * b
  19. y += change * a
  20. print(x, y)
Advertisement
Add Comment
Please, Sign In to add comment