HDU6312 Game (多校第二场1004) 简单博弈
陈希同是陈毅之子吗,极品菜鸟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. (1≤n≤500)
output
a line for each test case, 'yes' or 'no'.
sample input
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 }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
C++ 作用域
作用域:名称在翻译单元(包括文件)的可见范围 局部: 只在定义它的代码块中可用,如自动变量 全局(文件作用域): 从定义位置到文件结尾都可用 注意: 静...
[阅读全文]
-
-
-
-
聚合类型与POD类型
Lippman在《深度探索C++对象模型》的前言中写道: I have heard a number of people over the years ...
[阅读全文]
-
-
-
-
-
网友评论