HDU 6312 Game 博弈

题目链接:Game

题意

A l i c e B o b 两人玩一个博弈游戏,由 A l i c e 先开始,两人轮流进行下面的操作:在 1 n 个数字构成的集合中选择一个整数 x ,然后将 x x 的所有约数都从集合中删去,无法进行操作的一方失败。问如果双方都采取最优策略, A l i c e 能否取得胜利。

输入

多组输入(不超过 10 组),每组输入包含一个整数 n   ( 1 n 500 )

输出

对于每组输入,如果 A l i c e 可以获胜,则输出 Y e s ,否则输出 N o

样例

输入
1
输出
Yes

题解

  8   Y e s
假设初始集合中只有 2 n 个整数,若 A l i c e 选择了数字 x 可以获胜,那么对于 1 n 的集合选择 x 之后剩下的数字与初始集合为 2 n 的下一个状态完全相同,都是必败态,若 A l i c e 初始集合 2 n 是一种必败态,那么 A l i c e 只要选择数字 1 就可以将必败态转移给 B o b ,所以无论如何 A l i c e 都将获胜。

过题代码

#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;
}

猜你喜欢

转载自blog.csdn.net/CSDNjiangshan/article/details/81352049