Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 7046 | Accepted: 2098 |
Description
Georgia and Bob move the chessmen in turn. Every time a player will choose a chessman, and move it to the left without going over any other chessmen or across the left edge. The player can freely choose number of steps the chessman moves, with the constraint that the chessman must be moved at least ONE step and one grid can at most contains ONE single chessman. The player who cannot make a move loses the game.
Georgia always plays first since "Lady first". Suppose that Georgia and Bob both do their best in the game, i.e., if one of them knows a way to win the game, he or she will be able to carry it out.
Given the initial positions of the n chessmen, can you predict who will finally win the game?
Input
Output
Sample Input
2 3 1 2 3 8 1 5 6 7 9 12 14 17
Sample Output
Bob will win Georgia will win
import java.util.Arrays;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
while(T-->0){
int N=sc.nextInt();
int[] a=new int[N+1];
for(int i=1;i<=N;i++)
a[i]=sc.nextInt();
Arrays.sort(a);
int result=0;
for(int i=N;i>=1;i-=2){
result^=(a[i]-a[i-1]-1);
}
if(result==0)
System.out.println("Bob will win");
else
System.out.println("Georgia will win");
}
}
}