A Game of 2
Easy Accuracy: 11.12% Submissions: 1190 Points: 2

One day Karan and Arjun were playing a game. The game always starts with Karan as he is the younger brother among the two and thereafter play alternate turns. They always try to show their power to each other but this time they decided to show it with numbers. Both of them like the number 2. So they decided to play it with 2. First they decide a random number n and then they take some actions on the number n. If they found that number is not a power of 2, then they reduce the number by the largest power of 2 less than the number and if they found that the number is a power of 2, they simply reduces the number by the half. Then they perform the same operations with the new number generated until the number n becomes 1 and further no one can play the game. The last person to make a valid move will win the game.

The first line contains an integer T, the number of test cases. Then T test cases follow. Each test case will contain an integer n, denoting the starting number.

For each test case in a new line print the winner of the game.



For first test case 6 is not a power of 2 Karan takes the largest power of 2 less than 6 which is 4 in this case and reduces the n to 2. Now 2 is a power of 2 therefore Arjun reduces it to half and number becomes 1 and afterwards Karan cannot make a move and therefore lose the game.


to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.