help-the-hungry-grasshopper

Today grasshopper Jimmy Jumper is very hungry and his friend is notorious. Jimmy's friend puts an insect infront of him at a distance d. Jimmy can jump only a finite no of steps in each turn. Jimmy is initially at position 0. He can now jump 1 step to reach position 1 then jump 2 steps to reach position 3 then jump 4 steps to position 7 and so on.

Since Momu is very hungry and could not take risk of jumping but not reaching to the destination point, so you have to tell him whether he can reach to position d or not.

Input: 

First line contains t test cases.
Next t lines contains an integer d.

Constraints:

1 ≤ t ≤ 10

1 ≤ d ≤ 10^9

Output: 

t lines each containing "YES" if he can reach or "NO" if cannot   

Test case:

Input:

3

3

15

5

Output:

YES

YES

NO

SAMPLE INPUT
3
3
15
5

SAMPLE OUTPUT
YES
YES
NO

Source: hackerearth | Difficulty: EASY


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
from math import sqrt
t=eval(input())
while t>0:
	t-=1
	n=eval(input())
	a=0
	b=1
	while(a<n):
		a+=b
		b*=2
	if n==a:
			print("YES")
	else:
		print("NO")