#P1431. 找出伪币
找出伪币
Description
You are given a bag containing coins. Among the coins, exactly one is counterfeit, and its weight is different from that of a genuine coin. Your task is to find this counterfeit coin.
To help you, you are given a device that can compare the weights of two groups of coins, e.g., a balance scale. Using this device, you can tell whether the two groups have the same total weight.
Input Format
The first line contains a positive integer , the number of test cases.
Then follow lines, each containing three positive integers .
: the counterfeit coin is lighter; : the counterfeit coin is heavier; : you do not know whether the counterfeit coin is lighter or heavier.
is a -digit positive decimal integer (with no leading ).
Output Format
Output lines, each containing an integer , the minimum number of weighings that guarantees finding the counterfeit coin.
2
1 1 6
1 0 6
2
3
Hint
For of the testdata, .
For of the testdata, , , .
When , you also need to determine whether the counterfeit coin is lighter or heavier than a genuine one.
Translated by ChatGPT 5
京公网安备 11011102002149号