p129ex3 - Powers of 2
Write a program that reads a positive integer and then finds the smallest power of two greater than or equal to the number that was read.
Each test case will input a single integer number.
You are to output a single integer number.
Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 22, 2008
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
The sample output is 8 because 2^8 = 256 > 200 > 128 = 2^7.
Waiting for other submissions to finish...
When I run your code (submission 51610), it doesn't even work on the sample data.
Output the exponent A where 2 to the power of A is <= to N.
P.S. The output was wrong for 2 cases, but I changed that.