No.102 Steal the Playing Cards
タグ : / 解いたユーザー数 193
作問者 :
Problem Statement
Taro and Jiro found some playing cards on a desk, stacked separately by suit (♤♡♢♧).
So the two of them decided to play a game using these as 4 piles.
The rules of the game are as follows.
・4 piles are prepared on the table.
・The players take turns taking cards from the piles and adding them to their hands.
・In one turn, a player may take only 1 to 3 cards from a single pile (a player cannot take cards from multiple piles at once).
・A player cannot pass and must take at least 1 card.
・For each of the 4 piles, the player who takes its last card can steal half of the opponent's hand (rounded up if the number of cards is odd).
・When all piles are gone, the player with more cards in hand wins.
Taro and Jiro have clairvoyance, so they know the number of cards remaining in each pile, and they can read each other's minds by telepathy, so they always play optimally.
Given the number of cards in the 4 piles,
output which of Taro and Jiro wins when Taro moves first.
Input
$N_1\ N_2\ N_3\ N_4$
The number of cards $N\ (1 \leq N \leq 13\ )$ in each of the 4 piles is given.
Output
Output the name of the winning player ("Taro" or "Jiro"), or "Draw" in the case of a draw. (The quotation marks are not needed.)
Print a newline at the end.
Sample
Sample 1
Input
1 1 1 1
Output
Jiro
The game proceeds as follows, and Jiro wins.
1. First player (Taro) takes 1 card from pile 1. (He took the last card of pile 1, so he can take half from the opponent, but the opponent has 0 cards, so nothing changes.)
Taro: 1 Jiro: 0 Piles: 0 1 1 1
2. Second player (Jiro) takes 1 card from pile 2. He took the last card of pile 2, so he takes half (1/2 rounded up, which is 1 card) from the opponent.
Taro: 0 Jiro: 2 Piles: 0 0 1 1
3. First player (Taro) takes 1 card from pile 3. He took the last card of pile 3, so he takes half (1 card) from the opponent.
Taro: 2 Jiro: 1 Piles: 0 0 0 1
4. Second player (Jiro) takes 1 card from pile 4. He took the last card of pile 4, so he takes half (1 card) from the opponent.
Taro: 1 Jiro: 3 Piles: 0 0 0 0
Jiro wins 1 to 3.
Sample 2
Input
1 2 3 2
Output
Taro
1. First player (Taro) takes 2 cards from pile 3.
Taro: 2 Jiro: 0 Piles: 1 2 1 2
2. Second player (Jiro) takes 1 card from pile 2.
Taro: 2 Jiro: 1 Piles: 1 1 1 2
3. First player (Taro) takes 1 card from pile 4.
Taro: 3 Jiro: 1 Piles: 1 1 1 1
4. Second player (Jiro) takes 1 card from pile 1. He took the last card of pile 1, so he takes half (rounded up, 2 cards) from the opponent.
Taro: 1 Jiro: 4 Piles: 0 1 1 1
5. First player (Taro) takes 1 card from pile 2. He took the last card of pile 2, so he takes half (2 cards) from the opponent.
Taro: 4 Jiro: 2 Piles: 0 0 1 1
6. Second player (Jiro) takes 1 card from pile 3. He took the last card of pile 3, so he takes half (2 cards) from the opponent.
Taro: 2 Jiro: 5 Piles: 0 0 0 1
7. First player (Taro) takes 1 card from pile 4. He took the last card of pile 4, so he takes half (rounded up, 3 cards) from the opponent.
Taro: 6 Jiro: 2 Piles: 0 0 0 0
Taro wins 6 to 2.
Jiro tried other ways of taking cards as well, but it seems he cannot win in this pattern.
Sample 3
Input
3 6 12 4
Output
Taro
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。