Nim x Nim

All submissions for this problem are available.
Gon and Killua love playing games. One day, they came across the game of [Nim](https://en.wikipedia.org/wiki/Nim), but soon got disinterested once they found the winning strategy. Thus they created a new game, “Nim x Nim”. The game is similar to singlepile Nim, except that in each turn, a player can take only 1 to $ceil(n/x)$ stones from the pile, where $n$ is the number of stones in the pile, $x$ is an integer parameter fixed at the beginning of the game and $ceil$ is the [ceiling function](https://en.wikipedia.org/wiki/Floor_and_ceiling_functions). They enjoyed playing this game, with Gon playing first every time, but soon got curious: given a particular $n$ and $x$, and assuming that players play optimally, is it possible to predict the winner? Help them out! ###Input:  The first line contains 2 integers $x$ and $t$, the parameter for Nim x Nim and the number of test cases.  $t$ lines follow, each of which contains a single integer $n$, the number of stones in the pile at the beginning of each game. ###Output: For each test case, if the first player can win assuming both players play optimally, in a new line, print “Gon”, else print “Killua”. ###Constraints  $1 \leq x \leq 5\times 10^6$  $1 \leq t \leq 10^6$  $0 \leq n \leq 5\times 10^6$ ###Sample Input: 2 6 1 2 3 4 5 6 ###Sample Output: Gon Killua Gon Gon Gon Killua ###EXPLANATION: For $n=1$ and $x=2$, on the first turn, Gon can remove at most $ceil(1/2)=1$ stone. Since removing one stone will make Gon win the game, "Gon" is printed. For $n=2$ and $x=2$, on the first turn, Gon can remove at most $ceil(2/2)=1$ stone. Thus, the only move available to him is to remove one stone, and now $n$ becomes 1. Killua can remove $ceil(1/2)=1$ stone on his turn and win the game, so "Killua" is printed.Author:  teja349 
Tags  teja349 
Date Added:  6042018 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions