Card Game
Time limit1sMemory limit512 MB
Two players alternately remove a chosen card and every card with a smaller number; decide the winner under optimal play.
- Level
Hard8 of 10
- Topics
- Game theory, Dynamic programming, Bit manipulation, Sorting
- Solved
- No attempts yet
Problem
Koosaga and Cubelover are about to play a card game. The game starts with cards, each with an integer written on it, arranged in a row. The number on the -th card is .
The players take turns, and Koosaga moves first. Each turn works as follows.
- Choose one card and remove it. All cards with a number smaller than the number on the chosen card are also removed.
- That is, if the -th card is chosen, then the -th card and every -th card satisfying are removed.
When all cards are removed, the game ends, and the player with no card left to remove loses. Write a program that determines the winner when both players play optimally.
Input
The first line gives the number of cards, . The second line gives the numbers written on the cards, .
Output
Print "koosaga" if Koosaga wins, and "cubelover" if Cubelover wins.
Constraints
Hint
In the first example, if Koosaga chooses 7, every card is removed, so Cubelover cannot win. In the second example, no matter which card is removed, one card remains. Therefore, Cubelover wins.