NOVICE63 - Special Numbers

no tags 

Ted thinks that integers having equal number of 1's and 0's in their binary representation are special. Therefore, he wants to know how many such integers are present.

Note: For this problem, the binary representation of an integer(>0) is considered from the least significant bit to the last set bit. Which means, 5 has a binary representation of 101, 3 has a binary representation of 11 etc. As such, one example of a special number is 9 which has a binary representation, 1001.

Input

First line contains an integer T (at most 100) denoting the total number of test cases. Each test case contains a single integer N (2 <= N <= 2^60). N is always a power of 2.

Output

A single integer denoting the total number of such special numbers in the range 1 to N (inclusive).

Example

Input:
3
8
16
32

Output:
1
4
4

hide comments
Mitch Schwartz: 2014-01-08 20:46:27

@Rohan Phadke: You are asking for people to post spoilers. Please don't.

BLANKRK: 2013-11-03 06:48:44

yup!! in one go... :)

Onkar Nath Gupta: 2013-08-13 08:52:31

more test cases please !!!

chk: 2013-07-20 20:52:53

keep track of the data types..costed me WAs..
finally AC :)

pika_pika: 2013-06-29 06:22:59

i don't under stand why my code gives an error of '1' in the cases of 2^58,2^59,2^60 ... and rest of the answers are correct. I use python 3.2 so there should not be any precision errors?? any reason?? and thanks @__KIRA__ .. the test cases helped a lot

quintillion: 2012-12-23 08:23:36

@KIRA
your o/p is correct.... just confirm your o/p for N=2 it should be 1 :)

Snehasish Roy ;): 2012-08-20 19:52:26

Piece of Cake :)
300th user :)

Last edit: 2012-08-20 19:52:59
Tarun Gehlaut: 2012-07-04 17:44:47

I just cant get it..WA though my solutions seems perfectly OK...

Vaishnavh: 2012-07-01 08:07:10

@_KIRA_ I got the same set of answers. However I am not sure if you can output the answer as a float. Anyway, I am getting WA too :(

~neo~: 2012-02-21 12:01:26

ans for 2^60 is 79296558016177761 = ?(Y or N).

Last edit: 2012-02-21 12:05:40

Added by:amit karmakar
Date:2011-07-02
Time limit:0.300s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own problem used in - http://www.spoj.pl/NOVICE6/