HDUOJ6312Game

HDUOJ6312Game

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

1

Sample Output

Yes

题意

A和B从1 - n的n个数字中轮流选择一个数字,然后在序列中删去每一个被选的数字和它的所有因子,第一个没有可选数字的人为loser,A为先手
问Alice能不能赢

思路

1为所有数字的因子,
所以都先不选1
当结果为Alice输的时候再在前面加个选1
当结果为Alice赢的话就酱
所以吖先手总能赢
(打扰了,看到Alice和Bob就觉得是博弈就没看)

AC代码

#include<iostream>
using namespace std;
int main()
{
    int n;
    while (cin >> n)
    {
        cout << "Yes" << endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/wuswi0412/article/details/81273739
今日推荐