P15469 [HackerRank] Solve equations
普及
题目描述

You are given a straight line, $a\cdot x+b\cdot y=c$. Find the point closest to the origin that also satisfies the following properties:

$\boldsymbol{x}$ and $y$ are integers.
$\boldsymbol{x}$ is greater than zero.

If more than one solution exists satisfying $\mbox{1}$ and $2$, then choose the point in which $\boldsymbol{x}$ is minimal.

Given $\textit{q}$ queries consisting of $a_i$, $b_i$, and $c_i$, find and print the point satisfying the above conditions for each respective query. Each point must be printed on a new line as two space-separated integers denoting the point's respective $x_i$ and $y_i$ values.

Note: It is guaranteed that there will always be integral points on the line.

Input Format

The first line contains an integer, $\textit{q}$, denoting the number of queries.

Each line $\boldsymbol{i}$ of the $\textit{q}$ subsequent lines contains three space-separated integers describing the respective values of $a_i$, $b_i$, and $c_i$ for the query.

Constraints

$1\leq q\leq10^5$
$1\leq a\leq10^8$
$1\leq b\leq10^8$
$1\leq c\leq10^8$

Output Format

For each query, print $2$ space-separated integers on a new line denoting the respective values of $x_i$ and $y_i$ for the point satisfying the $i^{\mbox{th}}$ query.

Sample Input
1
2 3 1

Sample Output
2 -1

Explanation

Given the line $2\cdot x+3\cdot y=1$, the point $(2,-1)$ is on the line and satisfies the conditions specified above. Thus, we print the coordinate as two space-separated integers on a new line.

输入格式

见题面

输出格式

见题面

样例输入
1 2 3 1
样例输出
2 -1