ZOJ Problem Set - 3753
There are many Equations. Some are difficult to solve, for example: an xn + an-1 xn-1 + .. + a0 = 0.
In this problem, you are given a simple equation: AX + BY = XY. To simplify the problem, here A, B, X, Y are positive integers. Your task is to find the solution (X, Y) of this equation where X is not less than M. If there are multiple solutions, you should choose the solution with the minimal X + Y. If there are still ties, you should choose the solution with the minimal X.
There are multiple test cases (about 3000). For each test case:
There is only one line contains three integers A, B (1 <= A, B <= 10 ^ 9) and M (1 <= M <= 10 ^ 18).
For each test case, output X and Y. If there is no valid solution, output "No answer" instead.
1 1 2 1 1 3 3 4 8 3 4 9
2 2 No answer 8 6 10 5
Author: LIANG, Mingqiang
Source: ZOJ Monthly, January 2014