Time Limit:1s | Memory limit:32M |
Accepted Submit:552 | Total Submit:2586 |
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.
1 ABCD EFGH even ABCI EFJK up ABIJ EFGH even
K is the counterfeit coin and it is light. http://acm.fzu.edu.cn/problem.php?pid=1003 这一题看起来很难,其实想明天了思路也很清析,主要是strchr()这个函数的用法,判断某个字符在某个字符串中是否出现过。 其功能是:返回首次出现c字符的位置的指针,如果s中不存在c则返回NULL。 |