NOVICE63 - Special Numbers

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

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/

hide comments
2012-01-10 07:49:02 Jitesh
can't get it where i m wrong....can some one give some more test cases......

Plz some one post some more test cases or tell me where I'm wrong.....I'm getting a WA again and again....

Last edit: 2012-01-12 13:45:29
2011-12-29 18:04:07 BOND
@sourabh singh
no, your answers are not correct.
2011-12-28 08:40:26 Sourabh Singh
@amit karmakar
can u luk into point out whr m i getting it wrong coz m getting it ryt on my pc.
ID 6255292
2011-12-28 08:15:49 Sourabh Singh
i m getting
144115188075855872 5130634330054016
72057594037927936 5130634330054016
36028797018963968 1306288411057536
18014398509481984 1306288411057536
9007199254740992 332818957147520
4503599627370496 332818957147520
2251799813685248 84859707399552
1125899906842624 84859707399552

are output correct??. cozz it's giving wa
2011-12-25 18:36:58 BOND
@MR.BEAN
NO... just think like you are in 12th grade, solving a math question...
this hint would be sufficient i guess...
NOTE-- use cout << endl; to break the line.costed me a lot. don't know why !
2011-12-25 13:31:56 MR. BEAN
precomputation ?????
2011-09-03 17:13:44 Pandian
My problem works fine but wrong answer. wat could be the possible reason? Pls help me. is there any specific test case of larger number? Thanks.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.