码迷,mamicode.com
首页 > 编程语言 > 详细

hdu 1850 Being a Good Boy in Spring Festival(Nimm Game)

时间:2015-08-16 21:02:44      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

题意:Nimm Game

思路:Nimm Game

技术分享
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int m,a[128],i,sum,ans;
    while(~scanf("%d",&m)&&m){
        sum=0;
        for(i=0;i<m;++i){
            scanf("%d",&a[i]);
            sum^=a[i];
        }
        if(sum){
            ans=0;
            for(i=0;i<m;++i)
                if((sum^a[i])<a[i])++ans;//优先级
            printf("%d\n",ans);
        }
        else printf("0\n");
    }
    return 0;
}
View Code

 另:HDU 1850 Being a Good Boy in Spring Festival(博弈·Nim游戏)

hdu 1850 Being a Good Boy in Spring Festival(Nimm Game)

标签:

原文地址:http://www.cnblogs.com/bofengyu/p/4734849.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!