QCJ3 - The Game
Tom and Hanks play the following game. On a game board having a line of squares labelled from 0, 1, 2 ... certain number of coins are placed with possibly more than one coin on a single square. In each turn a player can move exactly one coin to any square to the left i.e., if a player wishes to remove a coin from square i, he can then place it in any square which belongs to the set (0, 1 ... i-1) . The game ends when all coins are on square 0 and player that makes the last move wins. Given the description of the squares and also assuming that Tom always makes the first move you have tell who wins the game (assuming both play optimally).
Input
The first line will contain N the number of test cases and then 2N lines follow. For each test case the first line will have S the size of the board and in the next line S integers follow. The ith integer gives the the number of coins in the ith square (starting from 1) . At least one of the S integers will be non zero. All the numbers in the input will be less than 25.
Output
For each test case output one line containing either "Tom Wins" or "Hanks Wins".
Example
Input: 2
1
1
1
2
Output: Tom Wins
Hanks Wins
hide comments
Simes:
2024-06-30 08:50:19
"...and in the next line S integers follow." Except the example input has one integer per line. |
|
backtobas:
2020-11-02 13:14:19
The logic is simple but I am getting WA |
|
ayusofayush:
2018-08-31 18:43:45
simple game of Nim.....game theory |
|
mmz33:
2016-07-24 21:21:23
Nice problem!
|
|
xxbloodysantaxx:
2016-06-01 12:10:42
Had to see the solution.
|
|
AC Srinivas:
2012-08-31 18:18:27
@problem setter: pls check submission id- 7568899. i know the logic, but WA. |
|
Arunkumar:
2011-11-14 18:21:59
min fo emag |
|
Santiago Zubieta:
2011-06-07 08:07:08
T.Hanks |
|
Seshadri R:
2010-05-03 04:36:48
Will square 0 be empty, when the game starts? Otherwise, how would the first (and the second) test cases in the Input be explained? |
|
Miorel-Lucian Palii:
2010-02-03 15:10:25
I just lost the game. |
Added by: | abhijith reddy d |
Date: | 2010-02-01 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | Own |