#P7471. [NOI Online 2021 入门组] 切蛋糕
[NOI Online 2021 入门组] 切蛋糕
Problem Description
Alice, Bob, and Cindy, three good friends, got a circular cake and plan to share it.
Their required amounts are , respectively. Now please help them cut the cake under the following rules:
-
Each time you cut the cake, you may choose any diameter of the cake and make one cut along this diameter (note that after cutting, the cake will not be immediately separated into two parts).
-
Suppose you make a total of cuts. Then you will obtain sector-shaped pieces of cake (in particular, making cuts is considered to give one sector, i.e., the whole circular cake). Distribute these pieces to Alice, Bob, and Cindy, and each sector-shaped piece must be given entirely to exactly one person.
-
The ratio of the cake areas received by the three people must be (it is not guaranteed to be in simplest form, and if some number in is , it means that person does not eat cake).
To complete this task, what is the minimum number of cuts you need to make?
Input Format
This problem contains multiple test cases in a single test point.
The first line contains an integer , representing the number of test cases.
The next lines each contain three integers , representing the required amounts of the three people.
Output Format
Output lines. The output on the -th line indicates the minimum number of cuts needed for the -th test case.
6
0 0 8
0 5 3
9 9 0
6 2 4
1 7 4
5 8 5
0
2
1
2
3
2
Hint
Explanation for Sample

Constraints and Notes
of the testdata satisfies: .
of the testdata satisfies: .
of the testdata satisfies: ,and it is guaranteed that .
The testdata is provided by SSerxhs.
Translated by ChatGPT 5