zoukankan      html  css  js  c++  java
  • POJ 1740 A New Stone Game(多堆博弈找规律)

    传送门

    //有n堆,AB轮流从n堆的一堆中移任意个,可以扔掉,也可以移给其他堆中的一堆
    //最先移完的胜
    //如果n堆中两两堆数目相等,那肯定是B胜
    //但只要有非两两相同的,如xyz,A先,
    //A可以从最多的那堆(z)移y-x个到x堆,yyp,最终移走p的一定是A
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    
    int main()
    {
        int n,a[105];
        while(scanf("%d",&n)&&n)
        {
            int aa,res=0,maxn=0;
            memset(a,0,sizeof(a));
            for(int i=0;i<n;i++)
            {
                scanf("%d",&aa);
                maxn=max(maxn,aa);
                a[aa]++;
            }
            for(int i=0;i<=maxn;i++)
            {
                if(a[i]%2==1)
                {
                    res=1;
                    break;
                }
            }
            printf("%d
    ",res);
        }
        return 0;
    }
  • 相关阅读:
    CSS样式表
    lianxi!
    传值
    lei!
    3.10
    if else&& stwitch break
    if else 语句
    2016.3.6
    进制转换
    PHP 面向对象的三大特征
  • 原文地址:https://www.cnblogs.com/atmacmer/p/5233298.html
Copyright © 2011-2022 走看看