Funny Number Game
Time limit0.5sMemory limit512 MB
Given a 4-digit N and M turns of incrementing one digit with 9 wrapping to 0, decide which player forces the final value above N.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Math, Game theory, Dynamic programming
- Solved
- No attempts yet
Problem
Koosaga and Cubelover play a "number game". The game proceeds as follows.
- Choose a 4-digit integer and a number of turns .
- Koosaga moves first, and the two players alternate turns.
- On your turn, pick one digit of the integer and increase it by 1. If the chosen digit is 9, it becomes 0.
For example, 3590 can be changed to one of 4590, 3690, 3500, 3591. After the game ends, if the integer is greater than , Koosaga wins; otherwise Cubelover wins. Both players play optimally.
Given and , write a program that determines the winner.
Input
The first line contains a 4-digit integer and .
Output
Print koosaga if Koosaga wins, and cubelover if Cubelover wins.