New Language CC
InterviewTime limit1sMemory limit512 MB
Given an integer n, print how many bits CC needs to store it after dropping leading zeros, with 0 stored in 1 bit.
- Level
Easy2 of 10
- Topics
- Bit manipulation, Math, Implementation
- Solved
- No attempts yet
Problem
In C, an int variable is stored as a binary number in 32 bits using two's complement.
For example, the integer 10 is stored as 0000 0000 0000 0000 0000 0000 0000 1010.
However, the world-shaking new language CC, to save memory, does not store the leading consecutive zeros when storing an int variable. That is, the integer 10 is stored as 1010. Every other aspect of storage is the same as in C.
Print the number of bits needed to store an integer n in CC. If n is 0, store it as 0 using 1 bit.
Input
The integer n to store in the language CC is given.
Output
Print the number of bits needed to store the variable n.
Constraints
- -2,147,483,648 ≤ n ≤ 2,147,483,647