Prime Jingle Bells
Time limit1sMemory limit512 MB
Two players alternately ring bells 1 to A times until the total reaches B; whoever rings on a prime-numbered count scores, and with optimal play we decide who wins.
- Level
Medium7 of 10
- Topics
- Game theory, Dynamic programming, Number theory, Math
- Solved
- No attempts yet
Problem
Kuro and Siro are playing a game. The rules are as follows.
- The two players take turns, and on a turn a player may ring the jingle bells at least time and at most times.
- The game ends the moment the total number of times the two players have rung the jingle bells reaches .
- A player scores 1 point each time the jingle bells are rung for a prime-numbered time.
- When the game ends, the player with the higher score wins.
Kuro and Siro are both very smart and always make the best choice. If Kuro starts first, who wins?
Input
The first line gives the number of test cases, an integer .
From the second line, each test case is given on one line as integers and separated by a space.
Output
For each test case, print kuro on its own line if Kuro wins, siro if Siro wins, and draw if the two have equal scores.