当前位置: 代码迷 >> C语言 >> 一道ACM的题,请教各位?
  详细解决方案

一道ACM的题,请教各位?

热度:124   发布时间:2007-08-14 10:28:56.0
一道ACM的题,请教各位?

Tom and Jack are on the train. The journey is too dull so much so that both of them are eager to find a way to fritter away the time. Tom is a student of mathematics department. He proposes a funny game to play with Jack. First pile up N chips where 1<N<100000, then Jack takes away at most P=N-1 chips from the pile. After that, Tom takes away at most(or equals) Q=2*P chips from the pile. Then it turns to Jack again, he takes away at most(or equals) P=2*Q. Each time both of them have to take away at least 1 chip. In the same way, the process continues and who takes away the last chip wins the game. Jack knows there must be something tricky in the game, so he's decided to write a program to check whether there exists a win-strategy(no matter how many chips Tom takes away each time, Jack will win) for himself for a specific N. You know Jack is very good at programming, so solving this problem doesn't take him too much time. Do you know how he does?

Input Specification

The input consists of several lines, each of which consists of an integer N. The last line of the input is 0, which you shouldn't process.

Output Specification

For each N, you should output either YES or NO. If there exists a win-strategy for Jack, output YES. Otherwise output NO.

Sample Input

2
3
4
5
1000
0

Sample Output

NO
NO
YES
NO
YES
搜索更多相关的解决方案: ACM  pile  chips  Jack  away  

----------------解决方案--------------------------------------------------------
英文的大意是什么
----------------解决方案--------------------------------------------------------
第一次最多取n-1个,下一次最多取走上一次取走的两倍
取走最后一个的那个人赢

[此贴子已经被作者于2007-8-14 10:42:19编辑过]


----------------解决方案--------------------------------------------------------
LZ``鸟语```厉害啊```
----------------解决方案--------------------------------------------------------
又按错``是LS```
----------------解决方案--------------------------------------------------------

说错了,当我没说过。

[此贴子已经被作者于2007-8-14 17:05:20编辑过]


----------------解决方案--------------------------------------------------------
大意是不是

Tom 和 Jack玩游戏,一堆东西有N个 (1<N<100000),Jack先取,最多取P=N-1个,然后是Tom取,最多取Q=2*P个,再Jack取,最多取P=2*Q个,继续取下去,直到取完最后一个,取到最后一个的人胜利,每个人最少取一个。

输入:
N(N不为0)
0 退出?

输出:(猜的)
如果Jack必胜,输出 YES
否则,输出 NO
----------------解决方案--------------------------------------------------------
看到这个题目,就知道外国人很闲,经常没什么事做,老是找一些东西玩
----------------解决方案--------------------------------------------------------
以下是引用totohack在2007-8-14 16:33:34的发言:
看到这个题目,就知道外国人很闲,经常没什么事做,老是找一些东西玩

。。。。。。。。。。。。。。。。。

-,-
----------------解决方案--------------------------------------------------------

以下是引用totohack在2007-8-14 16:30:56的发言:
大意是不是

Tom 和 Jack玩游戏,一堆东西有N个 (1<N<100000),Jack先取,最多取P=N-1个,然后是Tom取,最多取Q=2*P个,再Jack取,最多取P=2*Q个,继续取下去,直到取完最后一个,取到最后一个的人胜利,每个人最少取一个。

输入:
N(N不为0)
0 退出?

输出:(猜的)
如果Jack必胜,输出 YES
否则,输出 NO

谢谢你的翻译

1 No
2 No
3 No
4 Yes
5 No
6 Yes
7 No
8 Yes
9 No

自己推了几个小数据(不保证100%准确,但应该没有问题)
推论:在N>2后 if(N mod 2 = 0) then print "Yes" else print "NO"


----------------解决方案--------------------------------------------------------
  相关解决方案