mfgnik

Untitled

Jun 7th, 2020
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 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.     x *= c // d
  15.     y *= c // d
  16.     change = x // b
  17.     print(x - change * b, y + change * a)
Advertisement
Add Comment
Please, Sign In to add comment