POJ-1704 Georgia and Bob

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.