HDU6312 Game (多校第二场1004) 简单博弈
程序员文章站
2022-05-04 13:51:14
Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1340 Accepted Submission(s): 891 Problem Des ......
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'.
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)
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
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 }
上一篇: 利用OpenCV给图像添加中文标注