No.12 Coins

原文:

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值