English translate

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 有十几个 Voyageur 银元。然而,只有 11 枚硬币是真正的银元;一枚硬币是伪造的,即使它的颜色和大小使其与真正的银元无法区分。假币与其他硬币的重量不同,但 Sally 不知道它比真币重还是轻。
幸运的是,莎莉有一个朋友借给她一个非常准确的天平秤。这位朋友将允许莎莉称重三下以找到假币。例如,如果 Sally 将两枚硬币相互称重并且天平保持平衡,那么她就知道这两枚硬币是真实的。现在如果莎莉重
一枚真硬币与第三枚硬币之间的天平不平衡,那么莎莉知道第三枚硬币是假币,她可以分别根据放置它​​的天平是上升还是下降来判断它是轻还是重。
通过仔细选择她的称量,Sally 能够确保她能找到恰好三个称量的假币。

输入

输入的第一行是一个整数 n (n > 0),指定要遵循的案例数。每个案例由三行输入组成,每个称重行。 Sally 用字母 A--L 识别了每枚硬币。关于称重的信息将由两串字母给出,然后是单词“up”、“down”或“even”中的一个。第一串字母代表左边余额中的硬币;第二个字符串,硬币在正确的平衡。 (Sally 将始终将相同数量的硬币放在右侧天平上和左侧天平上。)第三个位置的单词将说明天平的右侧是上升、下降还是保持平衡。

输出

对于每种情况,输出将通过字母识别假币并判断它是重还是轻。解决方案将始终是唯一确定的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值