zoukankan      html  css  js  c++  java
  • Play Apple(博弈)

    Problem 1604 - Play Apple
    Time Limit: 1000MS   Memory Limit: 65536KB    Total Submit: 434  Accepted: 174  Special Judge: No
    Description

    There are N apples. Two people take turns to either:  1. Divide the apple into two piles with different numbers. 2. The other people selects a pile of apples as the beginning of the next turn. If someone can not meet the requirements, he is lost. Will the first one win the game if both use the best strategy?

    Input
    There are multiple test cases. The first line of each case contains a integer N. ( 1 <= N <= 1000000000 )
    Output
    If the first person will win, output “Yes”. Otherwise, output “No”.
    Sample Input
    2 3 4
    Sample Output
    No Yes No
    题解:题意是把一个数分两半,数字不能相同,一个人不能分就输了;挺好找的规律,一下就找到了,从开始找,两个必败对应必胜;否则必败;
    代码:
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    const int INF = 0x3f3f3f3f;
    typedef long long LL;
    int main(){
        LL N;
        while(~scanf("%lld",&N)){
            if(N == 1 || N == 2){
                puts("No");
            }
            else if(N == 3){
                puts("Yes");
            }
            else{
                if((N - 1) % 3 == 0){
                    puts("No");
                }
                else puts("Yes");
            }
        }
        return 0;
    }
  • 相关阅读:
    计算机图形学
    2017.3.20
    史上最强型人养成秘籍: 90 天肥仔变型男实录
    Word 2013发布博客测试
    eeeeeeeeeee
    测试,使用word2013发布博客园博客
    Win7系统桌面便签怎么添加?
    开启两步验证的教程
    【Todo】 cygwin下emacs中M-x shell 中出现乱码
    emacs的LoadPath
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5372839.html
Copyright © 2011-2022 走看看