当前位置: 移动技术网 > IT编程>开发语言>C/C++ > HDU6312 Game (多校第二场1004) 简单博弈

HDU6312 Game (多校第二场1004) 简单博弈

2018年09月18日  | 移动技术网IT编程  | 我要评论

陈希同是陈毅之子吗,极品菜鸟txt,落日海港

game

time limit: 2000/1000 ms (java/others)    memory limit: 32768/32768 k (java/others)
total submission(s): 1340    accepted submission(s): 891


problem description
alice and bob are playing a game.
the game is played on a set of positive integers from 1 to n.
in one step, the player can choose a positive integer from the set, and erase all of its divisors from the set. if a divisor doesn't exist it will be ignored.
alice and bob choose in turn, the one who cannot choose (current set is empty) loses.
alice goes first, she wanna know whether she can win. please judge by outputing 'yes' or 'no'.
 

 

input
there might be multiple test cases, no more than 10. you need to read till the end of input.
for each test case, a line containing an integer n. (1n500)
 

 

output
a line for each test case, 'yes' or 'no'.
 

 

sample input
1
 

 

sample output
yes
 
 
 
之前邀请赛的原题,当是写了几个数发现的规律。但是不知道为什么。。。。
 
 
其实可以把 1~n 转化为  2~n 
如果2~n 先手必败的话,那么先手可以第一次选1,把必败状态转移给后手;
如果2~n 先手必胜的话,多一个1其实是没有影响的。
证毕;
 
 
1 #include <bits/stdc++.h>
2 #define lowbit(x) (x)&(-x)
3 using namespace std;
4 int main()
5 {
6     int n;
7     while(~scanf("%d",&n))
8     cout<<"yes"<<endl;
9 }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网