BlueBook

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.

Input

Each test case will input a single integer number.

Output

You are to output a single integer number.

Sample Input

200

Sample Output

8

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 22, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

I don't understand what is wrong with my code and why doesn't it work?

You are not understanding the question; you only get the sample correct by happenstance.

The sample output is 8 because 2^8 = 256 > 200 > 128 = 2^7.


Waiting for other submissions to finish...

this happens when the judge is busy, you simply need to wait for the other problems to grade. this is usually something that takes less than a minute. just keep refreshing the page.

My code doesn't work for some reason...

Your output is incorrect when you input 1.
Remainder 2^0=1

My code works perfectly but the peg thing says it doesnt. help?

Why did you delay so long before asking? It makes it harder to track down your code.

When I run your code (submission 51610), it doesn't even work on the sample data.

never mind i got it...

The problem instructions have been updated, hopefully it makes sense now.

-Mr. Fenty

Read in one integer N (0 <= N <= 1000000).
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.

Toby Li.