11792 - Final Exam - Problem A   

Description

Given a positive integer N of int type, you are asked to find the maximum K such that N/(pow(2,K)) is a positive integer.

 

Input

The input is a positive integer N. (0<N)

Output

Please output pow(2,K).

 

Hint:

Suppose that N=12, then the answer is 4. Let’s convert 12 and 4 into binary:

/Users/ashley/Desktop/Screen Shot 2017-12-18 at 3.50.09 PM.png

You’ll notice that only the 3rd bit of 4 is the same as that of 12, which is 1, and the other bits are all 0. Please use this property to obtain the answer by simple bitwise operation and positive-negative sign conversion.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss