Ax+By=C
Time limit1sMemory limit1024 MB
Given integers A, B, C, find integer x and y with Ax + By = C within plus or minus one billion, or report that none exists.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Implementation, Brute force
- Solved
- No attempts yet
Problem
Given A, B, and C, find any pair (x, y) that satisfies Ax+By=C and the following conditions.
- x and y are integers
- -1,000,000,000 ≤ x, y ≤ 1,000,000,000
Input
The first line contains the integers A, B, and C.
Output
Print x and y satisfying Ax+By=C, separated by a space. If no (x, y) satisfies the conditions of the problem, print -1.
Constraints
- -1,000,000 ≤ A, B, C ≤ 1,000,000
- A, B ≠ 0