Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gcd_ext(first_num, second_num):
- if second_num == 0:
- return first_num, 1, 0
- d, x, y = gcd_ext(second_num, first_num % second_num)
- x, y = y, x - (first_num // second_num) * y
- return d, x, y
- a, b, c = map(int, input().split())
- d, x, y = gcd_ext(a, b)
- if c % d != 0:
- print(-1)
- else:
- a, b, c = map(lambda number: number // d, (a, b, c))
- x *= c
- y *= c
- change = x // b
- x -= change * b
- y += change * a
- print(x, y)
Advertisement
Add Comment
Please, Sign In to add comment