描述
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.
样例输入
1
ABCD EFGH even
ABCI EFJK up
ABIJ EFGH even
样例输出
K is the counterfeit coin and it is light.
参考代码
分享到:
相关推荐
北大POJ1013-Counterfeit Dollar 解题报告+AC代码
Forge是一个基于区块链的Web应用程序,用于打击产品假冒(当前实现为集中式应用程序,以使其更易于访问)。 演示图片 家 添加产品表格 仅可通过所有者帐户访问 添加产品后 显示嵌入可见键的二维码,该键可用于获取...
anti-counterfeit-android 模拟器检测,多开检测,Hook检测,Root检测。 4个Java类,直接拷贝使用即可。 模拟器检测 boolean isEmulator = EmulatorDetector.isEmulator(); 多开检测 boolean isVirtual = ...
JEDEC JESD243A:2021 Counterfeit Electronic Parts:Non-Proliferati
JEDEC JESD243A:2021 Counterfeit Electronic Parts:Non-Proliferation for Manufacturers - 完整英文电子版(18页).pdf
are literally a multibillion dollar business and growing at an unprecedented rate, impacting the profits of intellectual property (IP) holders as well as their corporate identities and reputation. Due...
超级漂亮的二次元模型 擅长二次元女性创作 适合对AI绘图感兴趣的小白 下载stable-diffusion-webui或者novelai-webui后 把ckpt模型放在models\Stable-diffusion\下 把vae模型放在models\VAE\下 ...
《Counterfeit Dollar》解题与算法分析报告 完全版
Counterfeit-V2.0稳定扩散扩散器
伪造 Counterfeit 是一个 AngularJS 模块,它为异步承诺提供测试替身。 这个库促进了返回承诺的函数的存根。 为用户提供轻松访问解决/拒绝虚假承诺的机会。安装通过 npm 安装模块$ npm install counterfeit --save-...
Android仿冒商品追踪器简单的Android客户端,可通过区块链的启发来处理跟踪商品的历史/完整性框架Android版Spring Jackson用于JSON序列化/反序列化参考后端回购: : 屏幕截图
Handle the counterfeit coin problem: a classic puzzle that consists of finding a counterfeit coin in a beam balance among eight coins in only two turns Cover Front Matter 1. The Bizarre and Awesome ...
1184 Counterfeit Dollar 简单题 1182 Keeps Going and Going and ... 简单题,我喜欢:) 1284 Perfection 简单题 1272 Numerically Speaking 简单题 1269 Coconuts, Revisited 简单题 1247 There s ...
比汉印和启锐面单打印机指令兼容更好 一个程序支持所有快递单软件 蓝牙打印 支持 顺丰 圆通 中通 易打单 烽火快递 快递100 TSPL ESCPOS 等指令集 几乎支持所有的快递APP 中通和申通快递内部APP 有数据握手加密没有做...
您的DS18B20温度传感器可能是伪造的,仿冒的... ...除非您直接从 (或以前的Dallas Semiconductor), (DigiKey,RS,Farnell,Mouser等)或大型零售商那里购买芯片,否则您会格外小心地购买防水的DS18B20探头。...
这是用于查询国际刑警通缉名单的实用程序脚本。 当前,这仅显示前9个结果。 例子 按姓氏搜索: [16:29:55] :gbuehler/interpol % python interpol.py --name jiang {"hair": "Black", "eyes": "Brown", "firstname...
Mock counterfeiter - 一个工具用于在Go中生成自容器,类型安全的测试Mock对象
1184 Counterfeit Dollar 简单题 1182 Keeps Going and Going and ... 简单题,我喜欢:) 1284 Perfection 简单题 1272 Numerically Speaking 简单题 1269 Coconuts, Revisited 简单题 1247 There s ...