Woburn Challenge 1995
Problem 2: Round Numbers
A positive integer N is said to be a "round number" if the binary representation of N has as many or more zeroes than ones. For example, the integer 9, when written in binary is form, is 1001. 1001 has two zeroes and two ones: thus 9 is a round number. The integer 26 is 11010 in binary; since it has two zeroes and three ones, it is not a round number.
Input
An integer K (1 ≤ K < 231)
Output
Indicate how many positive integers less than or equal to K are "round numbers" in the format shown below.
Sample Input
10
Sample Output
There are 5 round numbers less than or equal to 10.
All Submissions
Best Solutions
Point Value: 15 (partial)
Time Limit: 1.00s
Memory Limit: 16M
Added: Sep 29, 2008
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
Use dynamic programming!
:40:2: warning: no newline at end of file
: In function 'int main()':
:16: error: 'itoa' was not declared in this scope
Compile Failed.
My program compiles and works at home on Visual C++ Express Edition...
: In function 'int main()':
:21: error: 'itoa' was not declared in this scope
Compile Failed
It still fails...
Thanks Though! :(