hdu1907

这道题要对全部为1的情况特判,因为这种情况下与一般的nim游戏下不同

//============================================================================
// Name        : hdu1907.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int N, n, ans, tag;
int a[100];

int main() {
	scanf("%d", &N);
	while(N--){
		scanf("%d", &n);
		ans = 0;
		tag = 0;
		for(int i = 0;i < n;i++){
			scanf("%d", &a[i]);
			if(a[i]!=1)
				tag = 1;
		}
		if(tag)
		{
			for(int i = 0;i < n;i++){
				ans ^= a[i];
			}
			if(ans == 0) printf("Brother\n");
			else printf("John\n");
		}
		else{
			if(n%2 == 0) printf("John\n");
			else printf("Brother\n");
		}
	}
	return 0;
}

posted @ 2011-05-19 10:07  KOKO's  阅读(186)  评论(0编辑  收藏  举报