组合游戏(Nim 、反Nim)

详解见:http://wenku.baidu.com/link?url=H7XaRgujsbyWo3lQS5G2kXzzTgs-vS3-RvW3mVLEpKAjUgC94vPrBfkCXi4zxiavztczFR4-rk7X8h-ATZ_Xn_-5P0vRyV3f6LdZEeb6-YW 

             http://www.doc88.com/p-15628486495.html

里面有各种推论(博弈)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1907(反Nim)

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdio>

using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    int n, x, cnt, ans = 0;
    while(t--){
    while(~scanf("%d", &n))
    {
        ans = 0;
        cnt = 0;
        for(int i = 0; i < n; ++i)
        {
            scanf("%d", &x);
            ans ^= x;
            cnt += (x>1);
        }
        if((ans==0&&cnt==0)||(ans!=0&&cnt>=1)) puts("John");
        else puts("Brother");
    }
    }
    return 0;
}
同类型还有hdu 2509,

Nim 游戏:hdu 1524、hdu 1944、hdu 1536、hdu 5795

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值