原文:
Coins
1000ms 131072K
描述:
Snoopy has three coins. One day he tossed them on a table then and tried to flip some of them so that they had either all heads or all tails facing up. After several attempts, he found that regardless of the initial configuration of the coins, he could always achieve the goal by doing exactly two flippings, under the condition that only one coin could be flipped each time and a coin could be flipped more than once. He also noticed that he could never succeed with less than two flippings.
Snoopy then wondered, if he had n coins, was there a minimum number x such that he could do exactly x flippings to satisfy his requirements?
输入:
The input contains multiple test cases. Each test case consists of a single positive integer n (n < 10,000) on a separate line. A zero indicates the end of input and should not be processed.
输出:
For each test case output a single line containing your answer without leading or trailing spaces. If the answer does not exist, output “No Solution!
”
样例输入:
2 3 0
样例输出:
No Solution! 2
注释:
Source: POJ Monthly--2007.04.01, Snoopy
译文:
硬币
1000ms 131072K
描述:
Snoopy有三枚硬币,一天他把他们投掷在桌子上并尝试翻动其中的一些以使得三枚硬币全为正面或全为反面朝上。在几次尝试后,Snoopy发现,无论三枚硬币初始状态如何,在每次只能翻动一枚硬币,每枚硬币可以翻动多次的前提下,他总可以在翻动两次的情况下达到目的,他还注意到了有一些情况,不翻动两次他就不会成功。
Snoopy想知道,如果他有n枚硬币,那么使使达到上述目的翻动次数的最小值x是多少?
输入:
输入包含多行,每行代表一种输入情况,每一行包含一个正整数用来表示硬币的数量,当输入为零时表示输入结束,且该情况不用计算
输出:
每种情况对应一行输出结果,能找到结果时输出包含一个正整数,否则输出“No Solution!
”
样例输入:
2 3 0
样例输出:
No Solution! 2
注释:
Source: POJ Monthly--2007.04.01, Snoopy