3625 - Harry Potter and the Stones 3625 - Harry Potter and the Stones 3625 - Harry Potter and the Stones

Statistics Sub: 106 | AC: 65 | AC%: 61,32 | Score: 2,06
Created by Rubén Alcolea Núñez
Added by ralcolea (2016-04-27)
Limits
Total Time: 10000 MS | Test Time: 1000 MS |Memory: 512 MB | Output: 64 MB | Size: 9 KB
Enabled languages
Available in

Description

Harry and Ron are two good friends. Today, they learned an interesting game to practice their mental abilities, and the most important, they can play it without needing the use of magical spells. The game is very simple and it is played with a pile of N stones. Harry and Ron play by turns and Ron always plays first. The aim of the game is to remove stones in each turn until the pile becomes empty. The player who makes the last move wins the game, or equivalently, the first player unable to remove stones from the pile, loses the game. The game has the following rules:
  • The first player can remove as many stones as desired, at least one stone but not the whole pile.
  • Thereafter, the players alternate moving, each player may remove at most twice the number of stones his opponent removed on the previous turn.
Given the number of stones in the initial pile, help Harry and Ron to know which player wins the game if both players play optimally.
Harry and Ron are two good friends. Today, they learned an interesting game to practice their mental abilities, and the most important, they can play it without needing the use of magical spells. The game is very simple and it is played with a pile of N stones. Harry and Ron play by turns and Ron always plays first. The aim of the game is to remove stones in each turn until the pile becomes empty. The player who makes the last move wins the game, or equivalently, the first player unable to remove stones from the pile, loses the game. The game has the following rules:
  • The first player can remove as many stones as desired, at least one stone but not the whole pile.
  • Thereafter, the players alternate moving, each player may remove at most twice the number of stones his opponent removed on the previous turn.
Given the number of stones in the initial pile, help Harry and Ron to know which player wins the game if both players play optimally.
Harry and Ron are two good friends. Today, they learned an interesting game to practice their mental abilities, and the most important, they can play it without needing the use of magical spells. The game is very simple and it is played with a pile of N stones. Harry and Ron play by turns and Ron always plays first. The aim of the game is to remove stones in each turn until the pile becomes empty. The player who makes the last move wins the game, or equivalently, the first player unable to remove stones from the pile, loses the game. The game has the following rules:
  • The first player can remove as many stones as desired, at least one stone but not the whole pile.
  • Thereafter, the players alternate moving, each player may remove at most twice the number of stones his opponent removed on the previous turn.
Given the number of stones in the initial pile, help Harry and Ron to know which player wins the game if both players play optimally.

Input specification

The first line contains an integer C, (1 ≤ C ≤ 20) representing the number of games that Harry and Ron are going to play. The following C lines contain an integer N, (2 ≤ N ≤ 5000), the  number of stones in the pile before starting the game.
The first line contains an integer C, (1 ≤ C ≤ 20) representing the number of games that Harry and Ron are going to play. The following C lines contain an integer N, (2 ≤ N ≤ 5000), the  number of stones in the pile before starting the game.
The first line contains an integer C, (1 ≤ C ≤ 20) representing the number of games that Harry and Ron are going to play. The following C lines contain an integer N, (2 ≤ N ≤ 5000), the  number of stones in the pile before starting the game.

Output specification

The output contains C lines. Each line contains the string "Harry wins" (without the quotes) if Harry wins the game, or the string "Ron wins" (without the quotes) otherwise.
The output contains C lines. Each line contains the string "Harry wins" (without the quotes) if Harry wins the game, or the string "Ron wins" (without the quotes) otherwise.
The first line contains an integer C, (1 ≤ C ≤ 20) representing the number of games that Harry and Ron are going to play. The following C lines contain an integer N, (2 ≤ N ≤ 5000), the  number of stones in the pile before starting the game.

Sample input

5
3
8
10
20
100

Sample output

Harry wins
Harry wins
Ron wins
Ron wins
Ron wins

Hint(s)

http://coj.uci.cu/24h/
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/

Recommendation

We have carefully selected several similar problems: 3378 | 2441 | 3515 | 3573 | 3599 | 3147