HDU 3032 Lasker's Nim博弈

网上说的很详细了,我再多说就有些矫情了,Nim游戏的另一变体:Lasker's Nim游戏,也是为数不多的可以直接应用规律解的Nim模型。

//HDU-3032.cpp
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
//const double pai = acos(-1.0);
const double pai = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
typedef long long love_live;

int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
//    freopen("output", "w", stdout);
    freopen("input", "r", stdin);
#endif
    int n, m, i, j, k;
    int t;
    while(scanf("%d", &t) != EOF){
        while(t--){
            int ans = 0;
            scanf("%d", &n);
            for(i = 0; i < n; ++i){
                scanf("%d", &k);
                    if(k % 4 == 3){
                        ans ^= (k + 1);
                    }
                    else if(k % 4 == 0){
                        ans ^= (k - 1);
                    }
                    else{
                        ans ^= k;
                    }
                }
            if(ans == 0){
                printf("Bob\n");
            }
            else{
                printf("Alice\n");
            }
        }
    }
return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值