阅读806 返回首页    go 阿里云 go 技术社区[云栖]


hdu 1850 博弈 入门

   nim变形题,要求是第一种有多少种胜法,其实就是求去掉某一堆里的一些牌,后手有没有必输测量,也就是异或为0


/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int org[101];
int main()
{
    int n;
    while(~scanf("%d",&n)&&n)
    {
        int i,ans=0,temp=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&org[i]);
            temp^=org[i];
        }
        for(i=0;i<n;i++)
        {
            if(org[i]>(temp^org[i]))ans++;
        }
        printf("%d\n",ans);
    }
}


最后更新:2017-04-03 15:21:46

  上一篇:go hdu 1536 S-Nim sg函数
  下一篇:go MOM系列文章之 - JMS2 spec. 解读