#P10252. 线性变换
线性变换
Problem Description
You are given three non-negative integers . As long as , you may perform the following operation on any number of times (including times):
- Change to .
You need to find the minimum value of that you can obtain through these operations.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case, one line contains three integers .
Output Format
For each test case, output one integer per line, the answer.
2
6 2 4
5 3 16
6
-1
Hint
Sample explanation: For the first test case, $x = 6 \rightarrow 8 \rightarrow 12 \rightarrow \cdots$. Obviously, is the minimum value.
For the second test case, , and is the minimum value.
Constraints:
For of the testdata, , and .
For another of the testdata, .
For another of the testdata, .
For of the testdata, , and .
Translated by ChatGPT 5