# John

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 2095    Accepted Submission(s): 1133

Problem Description

Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. And so on. Please note that each player has to eat at least one M&M during his turn. If John (or his brother) will eat the last M&M from the box he will be considered as a looser and he will have to buy a new candy box. Both of players are using optimal game strategy. John starts first always. You will be given information about M&Ms and your task is to determine a winner of such a beautiful game.

Input

The first line of input will contain a single integer T – the number of test cases. Next T pairs of lines will describe tests in a following format. The first line of each test will contain an integer N – the amount of different M&M colors in a box. Next line will contain N integers Ai, separated by spaces – amount of M&Ms of i-th color. Constraints: 1 <= T <= 474, 1 <= N <= 47, 1 <= Ai <= 4747

Output

Output T lines each of them containing information about game winner. Print “John” if John will win the game or “Brother” in other case.

Sample Input

2 3 3 5 1 1 1

Sample Output

John Brother

Source

Recommend

lcy

//http://acm.hdu.edu.cn/showproblem.php?pid=1907
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;

int main()
{
int t,n,i,x;
bool flag ;
cin>>t;
while(t--)
{
scanf("%d",&n);
vector<int>num(n+1);
x=0,flag=false;
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
x^=num[i];
}
for(i=0;i<n;i++)
{
if(num[i]>1)
{
flag=true;
break;
}
}
if(flag)
{
if(x)     puts("John");
else    puts("Brother");
}
else
{
if(n&1)
puts("Brother");  //奇数 win
else
puts("John");   //偶数 win
}
}
return 0;
}

657 篇文章64 人订阅

0 条评论

## 相关文章

### hduoj------2594 Simpsons’ Hidden Talents

Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit:...

2724

### HDUOJ----1003 Max Sum

Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J...

2476

### POJ-1276-Cash Machine（多重背包）

Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions:...

2894

### POJ-1959 Darts

Darts Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1286 ...

36810

### HDU 3388 Coprime（容斥原理+二分）

Coprime Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (...

3345

2277

### hdu-----(1507)Uncle Tom's Inherited Land*(二分匹配)

Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others)    Memory Lim...

2554

### HDU 4745 Two Rabbits（区间DP，最长非连续回文子串）

Two Rabbits Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535...

3146

### HDU 5651 xiaoxin juju needs help

xiaoxin juju needs help Time Limit: 2000/1000 MS (Java/Others)    Memory Limit:...

2987

### HDUOJ--1159Common Subsequence

Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536...

2697