当前位置: 代码迷 >> 综合 >> Counterfeit Dolla(翻译)
  详细解决方案

Counterfeit Dolla(翻译)

热度:80   发布时间:2023-12-05 14:32:25.0

2022.2.8

题目网址:

http://noi.openjudge.cn/ch0201/15/

原题:

Counterfeit Dollar

总时间限制: 

1000ms

内存限制: 

65536kB

描述

Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit even though its color and size make it indistinguishable from the real silver dollars. The counterfeit coin has a different weight from the other coins but Sally does not know if it is heavier or lighter than the real coins.
Happily, Sally has a friend who loans her a very accurate balance scale. The friend will permit Sally three weighings to find the counterfeit coin. For instance, if Sally weighs two coins against each other and the scales balance then she knows these two coins are true. Now if Sally weighs
one of the true coins against a third coin and the scales do not balance then Sally knows the third coin is counterfeit and she can tell whether it is light or heavy depending on whether the balance on which it is placed goes up or down, respectively.
By choosing her weighings carefully, Sally is able to ensure that she will find the counterfeit coin with exactly three weighings.

输入

The first line of input is an integer n (n > 0) specifying the number of cases to follow. Each case consists of three lines of input, one for each weighing. Sally has identified each of the coins with the letters A--L. Information on a weighing will be given by two strings of letters and then one of the words ``up'', ``down'', or ``even''. The first string of letters will represent the coins on the left balance; the second string, the coins on the right balance. (Sally will always place the same number of coins on the right balance as on the left balance.) The word in the third position will tell whether the right side of the balance goes up, down, or remains even.

输出

For each case, the output will identify the counterfeit coin by its letter and tell whether it is heavy or light. The solution will always be uniquely determined.

翻译:

描述:

Sally Jones有一打旅行者银币。然而,这些硬币中只有11个是真的银币;这个伪造的硬币与其他硬币的重量不同但是Sally不知道真的硬币是更重还是更轻。

令人开心的是,Sally有一个借给她一个非常准确的天平的朋友。这个朋友承诺Sally三次称重就能找到这个伪造的硬币。例如,如果Sally称两个硬币一边一个并且天平平衡了,那么她就知道这两个硬币都是真的。现在如果Sally用这两个真硬币的其中一个与第三个称并且天平不平衡,那么Sally就知道第三个硬币是伪造的并且她能够根据天平放第三个硬币的一方上升还是下降来分别说出这个伪造的硬币更轻还是更重。

通过认真选择她的称重方式,实际上,Sally能够用3次称重来确保她将找到这个伪造的硬币。

输入:

输入的第一行是一个整数n(n>0)表示接下来有n组样例。每组样例有三行输入,是每次称重中的一次。Sally通过A到L识别每玫硬币。一次称重结果的信息将通过两个字符串被给出,然后它们是单词“up”,“down”,或者“even”中的一个。第一个字符串将代表天平左边的硬币;第二个字符串,代表天平右边的硬币。(Sally总是在天平两边放相同数量的硬币。)第三个位置的单词将表示天平右边是上升,下降,还是持平。

输出:

对于每个样例,输出将通过它的字母和说出它是更重还是更轻来确定这个伪造的硬币。答案总是唯一的。