QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2743|回复: 0
打印 上一主题 下一主题

ACM真题,哪个硬币不一样

[复制链接]
字体大小: 正常 放大

937

主题

117

听众

3万

积分

升级  0%

  • TA的每日心情

    2020-10-25 11:55
  • 签到天数: 264 天

    [LV.8]以坛为家I

    自我介绍
    内蒙古大学计算机学院

    社区QQ达人 金点子奖 助人为乐奖 风雨历程奖

    群组2013年数学建模国赛备

    跳转到指定楼层
    1#
    发表于 2013-8-8 11:55 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta
    Counterfeit DollarSally 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. ! {+ ~, P; A* L6 G

    0 a. {% a2 A9 X# I( ]$ i5 g9 F( m" b+ z' U; F6 R! B0 N6 T
    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.
    9 i. Y; v+ L) S$ p  d% {0 t( n& K1 c$ }, x6 d6 W, f
    7 b8 R. _$ j; a9 F- d$ w) P/ i( W  O
    By choosing her weighings carefully, Sally is able to ensure that she will find the counterfeit coin with exactly three weighings.
    & U5 t! Z$ G) Q/ q
    ) t; S4 j8 r, l, E( f4 h* a" ?6 R6 b3 v2 V* _% h% g5 r) S% f/ f
    Input
    ; w7 Q+ \& U' ^' g/ s* t& a$ U8 M' j: b
    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.
    ; X1 @3 Z+ M/ f, A# f. h
    3 a8 W# P/ U& Y: K
    ( f/ k9 n, c! _9 T1 _Output
    1 C# [+ y+ I* g+ }9 ]/ EFor 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. ; S9 X6 n8 e2 u2 n
    5 k& q( l% A! ^: r
    . W/ X. p; S* t3 b
    Sample Input
    2 Q5 ^+ Y5 q) d$ \* u1. b/ }9 @) y) J' S% v/ u
    ABCD EFGH even- @& e) B% A1 M+ y' w8 @& A
    ABCI EFJK up
    1 E. ]9 X& B& U  @9 v" \8 FABIJ EFGH even2 B6 d/ ]. Z% K/ {# x; J
    / p& m( ]* [% d9 Y( \! O8 {
    Sample Output; P! A2 t2 e: p  ?: r
    K is the counterfeit coin and it is light.4 `9 J7 _* F3 K; V5 u, O4 {' B
    . q# J- ]- s  E: _
    zan
    转播转播 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2024-4-27 07:47 , Processed in 0.286640 second(s), 51 queries .

    回顶部