POJ 1078 Gizilch 笔记

100个葡萄被标记为1到100号。两个人比赛吃葡萄,把每次吃到的葡萄数相乘为结果,最后自己报成绩,结果大的获胜。结果小的一方总是诚实的,如果结果大的一方撒谎,结果小的一方获胜。输出获胜一方的成绩。

展开阅读全文

Gizilch

01-26

nn问题描述 :nThe game of gizilch has very simple rules. First 100 grapes are labeled, in nontoxic ink, with the numbers 1 to 100. Then, with a cry of “GIZILCH!”, the referee fires the grapes up into the air with a giant gizilcher. The two players, who each start with a score of “1”, race to eat the falling (or, shortly thereafter, fallen) grapes and, at the same time, multiply their scores by the numbers written on the grapes they eat. After a minute, the hungry squirrels are let loose to finish the remaining grapes, and each contestant reports his score, the product of the numbers on the grapes he’s eaten. The unofficial winner is the player who announces the highest score.nnInevitably, though, disputes arise, and so the official winner is not determined until the disputes are resolved. The player who claims the lower score is entitled to challenge his opponent’s score. The player with the lower score is presumed to have told the truth, because if he were to lie about his score, he would surely come up with a bigger better lie. The challenge is upheld if the player with the higher score has a score that cannot be achieved with grapes not eaten by the challenging player. So, if the challenge is successful, the player claiming the lower score wins.nnnSo, for example, if one player claims 343 points and the other claims 49, then clearly the first player is lying; the only way to score 343 is by eating grapes labeled 7 and 49, and the only way to score 49 is by eating a grape labeled 49. Since each of two scores requires eating the grape labeled 49, the one claiming 343 points is presumed to be lying.nnOn the other hand, if one player claims 162 points and the other claims 81, it is possible for both to be telling the truth (e.g. one eats grapes 2, 3 and 27, while the other eats grape 81), so the challenge would not be upheld.nnUnfortunately, anyone who is willing to referee a game of gizilch is likely to have himself consumed so many grapes (in a liquid form) that he or she could not reasonably be expected to perform the intricate calculations that refereeing requires. Hence the need for you, sober programmer, to provide a software solution.nn输入:nPairs of unequal, positive numbers, with each pair on a single line, that are claimed scores from a game of gizilch.nn输出:nNumbers, one to a line, that are the winning scores, assuming that the player with the lower score always challenges the outcome.nn样例输入:nn343 49 n3599 610 n62 36nn样例输出:nn49 n610 n62 问答

没有更多推荐了,返回首页