閱讀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. 解讀