zoukankan      html  css  js  c++  java
  • HDU 6312

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6312

    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. (1n500)
     
    Output
    A line for each test case, 'Yes' or 'No'.
     
    Sample Input
    1
     
    Sample Output
    Yes

    题意:

    A和B玩游戏,有一个1~n的数字序列,规定每人每次能从里面挑出一个数,删去它以及他的因数,A先手,A想知道自己能不能赢。

    题解:

    假设现在是在2~n的序列里玩游戏,那么

      如果A先手情况下A是胜者,那么A就这么玩,因为1是任何数的因数,A还是能赢;

      如果A先手情况下B是胜者,那么A就先拿掉一个1,那么就变成2~n的序列下B先手,A就依然是胜者;

    综上,先手必胜。

    AC代码:

    #include<bits/stdc++.h>
    using namespace std;
    int main(){for(int n;cin>>n;) cout<<"Yes"<<endl;}
  • 相关阅读:
    如何判断哪个方法调用了相同的事件?
    Windows Update问题
    Android学习笔记
    关于官方Reachability Demo理解
    poj 1797 Heavy Transportation
    poj 3013 Big Christmas Tree
    poj 1062 昂贵的聘礼
    poj 3615 Cow Hurdles(floyd)
    CF Planets(STL+ 最短路)
    poj 3026 Borg Maze
  • 原文地址:https://www.cnblogs.com/dilthey/p/9370487.html
Copyright © 2011-2022 走看看