THE GAMEProblem code: QCJ6 |
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) . Given the description of the board 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. Atleast 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
| Author: | abhijith |
| Date Added: | 29-01-2010 |
| Time Limit: | 2 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

Game ends when all coints are
Game ends when all coints are on square 0
for the second case how can
for the second case how can you justify the o/p Hanks Win ?? There are no moves rt when only 1 square is there and all the coins are there in 0 square itself how can u say who wins ??
Beacuse there is no move when all the coins are already in 0 square.
In that case Tom should win both the games.
can any one tell me winning
can any one tell me winning condition plzzzz
What is the winning
What is the winning criteria??
what does optimal play mean?
what does optimal play mean?
@admin: What is the winning
@admin: What is the winning criteria?????
Read my first comment ! -> "
Read my first comment ! -> " Game ends when all coints are on square 0"
*coins
*coins
rather, Winner is the one who
rather, Winner is the one who moves the last coin on non-zero index to zero, thus leaving no chance of any moves to the other payer.