题目链接:Game
题意
和 两人玩一个博弈游戏,由 先开始,两人轮流进行下面的操作:在 到 个数字构成的集合中选择一个整数 ,然后将 及 的所有约数都从集合中删去,无法进行操作的一方失败。问如果双方都采取最优策略, 能否取得胜利。
输入
多组输入(不超过 组),每组输入包含一个整数 。
输出
对于每组输入,如果 可以获胜,则输出 ,否则输出 。
样例
输入 |
---|
1 |
输出 |
Yes |
题解
假设初始集合中只有 到 个整数,若 选择了数字 可以获胜,那么对于 到 的集合选择 之后剩下的数字与初始集合为 到 的下一个状态完全相同,都是必败态,若 初始集合 到 是一种必败态,那么 只要选择数字 就可以将必败态转移给 ,所以无论如何 都将获胜。
过题代码
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define LL long long
int n;
int main() {
#ifdef Dmaxiya
freopen("test.txt", "r", stdin);
#endif // Dmaxiya
ios::sync_with_stdio(false);
while(scanf("%d", &n) != EOF) {
printf("Yes\n");
}
return 0;
}