Submit | All submissions | Best solutions | Back to list |
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 ≤ 260). 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
|
||||||
2013-07-20 20:52:53 chk
keep track of the data types..costed me WAs.. finally AC :) |
||||||
2013-06-29 06:22:59 pika_pika
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 |
||||||
2012-12-23 08:23:36 quintillion
@KIRA your o/p is correct.... just confirm your o/p for N=2 it should be 1 :) |
||||||
2012-07-04 17:44:47 Tarun Gehlaut
I just cant get it..WA though my solutions seems perfectly OK... |
||||||
2012-07-01 08:07:10 Vaishnavh
@_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 :( |
||||||
2012-02-21 12:01:26 ~neo~
ans for 2^60 is 79296558016177761 = ?(Y or N). Last edit: 2012-02-21 12:05:40 |
||||||
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 |