DAY 5

4.2

6 votes
Problem

Jatin and Pranshu often play a game with a pile of N coins. In this game, Jatin and Pranshu make their respective moves alternately with Jatin beginning the game.

In a turn, a player can remove x coins from the pile if x satisfies :
a) 1<=x<=n
b)  x & n=0

where 'n' is the size of the pile in the current turn

The player who is unable to make a move loses the game.

Given the initial number of coins in a pile, determine who would win the game.
Assume that both the players play optimally throughout the game.

Input:
First-line denotes T  i.e. number of test cases
Next ‘T’ lines contain N where N is the number of coins in the pile as the game commences.

Output:
For each test case, print the winning player’s name (case sensitive).

Constraints:

1<=T<=105
1<=N<=1018

 

 

Time Limit: 0.5
Memory Limit: 256
Source Limit:
Explanation

1st test case: Jatin can't make a move so Pranshu won
2nd test case: Jatin can remove 1 coin because 1&2=0 then 1 coin left so Pranshu can't make a move so Jatin wins

Editor Image

?