×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

答案在此, 小括号中1, 2, 3为第几次称

本文发表在 rolia.net 枫下论坛A = {1, 2, 3, 4}
B = {5, 6, 7, 8}
C = {9, 10, 11, 12, 13}

if (A == B) (1)
{
answer in 9, 10, 11, 12, 13

D = {1, 9, 10}
E = {2, 5, 11}

if (D == E) (2)
{
answer in 12 or 13

if (1 == 12) (3)
answer is 13
else (3)
answer is 12
}
else (2)
{
answer in 9 or 10 or 11

if (9 == 10) (3)
{
answer is 11
}
else (3)
{
answer is 9 or 10

if (D > E) (2)
{
if (9 > 10) (3)
answer is 9 because D > E
else (3)
answer is 10 because D > E
}
else (2)
{
same as D > E
}
}
}
}
else (1)
{
if (A > B) (1)
{
F = {1, 5, 6}
G = {2, 7, 9}

if (F == G) (2)
{
answer in 3 or 4 or 8

if (3 == 4) (3)
answer is 8
else if (3 > 4) (3)
answer is 3 because A > B
else (3)
answer is 4 because A > B
}
else if (F > G) (2)
{
answer in 1 or 7, same as above answer in 12 or 13
}
else (2)
{
answer in 2 or 5 or 6, same as above answer in 9, 10, 11
}
}
else (1)
{
same as A > B
}
}更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 枫下沙龙 / 谈天说地 / 不是微软试题,13个球,有一个球和其他的重量不一样,外观一样。用一个天平称三次,把那个球找出来。你能做到吗?嘿嘿。。。
    • 有前提吗?那个球是重还是轻?
      • 只知道重量不一样,但不知道是重还是轻。自己判断吧。:)
        • 不对吧?(倒吸一口气)。
          • 要是知道轻重的话,就太简单了。;)
        • 这个这里早就有人贴过了,您就歇歇吧!
          • KAO,真的吗,那就给没看过的朋友解解闷儿吧。
          • 高手请指教, 如何用三次找出那个球?
    • 可以,给大家提示:先分成4/4/5。
    • 答案在此, 小括号中1, 2, 3为第几次称
      本文发表在 rolia.net 枫下论坛A = {1, 2, 3, 4}
      B = {5, 6, 7, 8}
      C = {9, 10, 11, 12, 13}

      if (A == B) (1)
      {
      answer in 9, 10, 11, 12, 13

      D = {1, 9, 10}
      E = {2, 5, 11}

      if (D == E) (2)
      {
      answer in 12 or 13

      if (1 == 12) (3)
      answer is 13
      else (3)
      answer is 12
      }
      else (2)
      {
      answer in 9 or 10 or 11

      if (9 == 10) (3)
      {
      answer is 11
      }
      else (3)
      {
      answer is 9 or 10

      if (D > E) (2)
      {
      if (9 > 10) (3)
      answer is 9 because D > E
      else (3)
      answer is 10 because D > E
      }
      else (2)
      {
      same as D > E
      }
      }
      }
      }
      else (1)
      {
      if (A > B) (1)
      {
      F = {1, 5, 6}
      G = {2, 7, 9}

      if (F == G) (2)
      {
      answer in 3 or 4 or 8

      if (3 == 4) (3)
      answer is 8
      else if (3 > 4) (3)
      answer is 3 because A > B
      else (3)
      answer is 4 because A > B
      }
      else if (F > G) (2)
      {
      answer in 1 or 7, same as above answer in 12 or 13
      }
      else (2)
      {
      answer in 2 or 5 or 6, same as above answer in 9, 10, 11
      }
      }
      else (1)
      {
      same as A > B
      }
      }更多精彩文章及讨论,请光临枫下论坛 rolia.net
      • 好容易对齐的括号给弄乱了. 大家自己费心再对齐
    • (1)天平左右各6个,在轻的那边或没放的那个 (2)左右各3个,在轻的那边(3)左右各1个,是轻的或没放的那个
      • 你的答案多了一个先决条件,现在没人告诉你坏的球是轻还是重。所以是错的。
    • 此题无解, 4次我就可以称出来,哈哈你还不死心?
      • Rolia 自动把空格珊了, 所以我楼上的答案难读. 你把答案COPY到EDITOR上, 按IF, ELSE 和 {} 重新 INDENT 一下(不会的话找个JAVA或C++或C的PROGRAMMER帮你), 就知道有解, 只是麻烦透顶.
        • 不麻烦,可是你这么做首先给每个球编号了,原题没有说除了天平, 还可以用其他工具嘿嘿
        • 不编号也一样, 只是得记性极好记住每一个球, 哈哈,
    • 此题有解,当然你的眼睛得贼亮..分的出哪个小球是左边的, 哪个右边的.. 嘿嘿... 原题是12个球, 现在发现13个也成啊
      • 后来我发现,17个球也可以。
        • 以前看过一篇文章讲n个球的称法, 有个公式可以算出最少的称重次数.
          • 去www.csdn.net里面的“算法”看看,这类东东多得事。