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 <= 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
|
||||||
2014-01-08 20:46:27 Mitch Schwartz
@Rohan Phadke: You are asking for people to post spoilers. Please don't. |
||||||
2013-11-03 06:48:44 BLANKRK
yup!! in one go... :) |
||||||
2013-08-13 08:52:31 Onkar Nath Gupta
more test cases please !!! |
||||||
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-08-20 19:52:26 Snehasish Roy ;)
Piece of Cake :) 300th user :) Last edit: 2012-08-20 19:52:59 |
||||||
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 |