Root Nim Game
Time limit1sMemory limit512 MB
Given piles of stones, a move replaces a pile of x with any y in [x^(1/4), sqrt(x)] with y < x; determine the winner under optimal play.
- Level
Medium7 of 10
- Topics
- Game theory, Math, Prefix sum
- Solved
- No attempts yet
Problem
Koosaga and Cubelover are going to play a Root Nim game. The game uses piles of stones, and pile has stones. The two players take turns. On each turn, a player must do the following.
- Choose one pile. Let be the number of stones in that pile.
- Choose an integer that satisfies and , then change the number of stones in the chosen pile to .
A player who cannot make a move loses the game.
Given and the number of stones in each pile, write a program that determines who wins. Both players play optimally. Koosaga moves first.
Input
The first line contains the number of piles (). The second line contains (), the number of stones in each pile.
Output
If Koosaga wins, print "koosaga". If Cubelover wins, print "cubelover".