Description
Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, number the grids from left to right by 1, 2, 3, ..., and place N chessmen on different gr IDs, as shown in the following figure for example:
Georgia and Bob move the chessmen in turn. Every time a player would choose a chessman, and move it to the left without going over any other chessmen or across the LE FT Edge. The player can freely choose number of steps the Chessman moves, with the constraint, the Chessman must is moved at Le AST one step and one grid can at most contains one single Chessman. The player cannot make a move loses the game.
Georgia always plays first since "Lady first". Suppose that Georgia and Bob both does their best in the game, i.e., if one of them knows a a-to-win the game, he or she w Ill is able to carry it out.
Given the initial positions of the N chessmen, can you predict who'll finally win the game?
Input
The first line of the input contains a single integer t (1 <= t <=), the number of test cases. Then T cases follow. Each test case contains the lines. The first line consists of one integer N (1 <= n <=), indicating the number of chessmen. The second line contains N different integers P1, P2 ... Pn (1 <= Pi <= 10000), which is the initial positions of the N chessmen.
Output
For each test case, prints a, "Georgia'll Win", if Georgia'll win the game; "Bob would win", if Bob would win the game; Otherwise ' not sure '.
Sample Input
2
3
1 2 3
8
1 5 6 7 9 12 14 17
Sample Output
Bob would win
Georgia would win
#include <cstdio>#include <algorithm>using namespace STD;intMain () {intT, a[1010];scanf("%d", &t); while(t--) {intN, ans =0;scanf("%d", &n); for(inti =0; i < N; i++)scanf("%d", &a[i]);ifN2) a[n++] =0; Sort (A, a + N); for(inti =1; i < N; i + =2) ans ^= a[i]-a[i-1] -1;if(ANS)puts("Georgia would win");Else puts("Bob would win"); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
POJ-1704 Georgia and Bob