An Evil Affair
All submissions for this problem are available.
Hansel and Gretel are made to play a not-so-sinister game under the influence of the evil witch's dark magic. The rules are as follows:
1. There are 'n' blocks at the beginning.
2. Each block is composed of a certain amount of chocolates.
3. Hansel initiates and then they take turns alternately at playing the game.
4. In every turn, the player can choose any block and break it into two unequal sub blocks.
5. A player loses the game when he/she is unable to do so in his/her turn.
Given the initial number of chocolates in every block, predict the outcome of the game. Assume that both Hansel and Gretel are playing optimally.
The first line of input consists of a single integer T denoting the number of test cases. Each test case begins with a line containing a single integer n. The next line contains n integers ij denoting the number of chocolates in jth pile.
For each test case, print the predicted winner - 'Hansel' or 'Gretel'.
1 ≤ T ≤ 103
1 ≤ n ≤ 102
1 ≤ ij ≤ 104
2 1 7 3 1 2 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.