All Tracks Basic Programming Bit Manipulation Basics of Bit Manipulation Problem

Help your roommate
Tag(s):

Easy

Problem
Editorial
Analytics

After performing a lot of experiments at the SEGP and EEDC Lab, you need a break. You see your roommate stuck at a math problem. He asks for your help and says he will give you party at the NC if you solve this problem for him.

The problem is:

Initially you are given the number 0. After each day the numberdoubles itself. At any day, you can add the number 1 any number of times during the day.

You are given a number N and you need to tell the minimum number of times you have to add 1 to get N at any point of time.

Since you are very hungry, solve this problem for him to get something to eat for free.

Input Format:

The first line contains a single integer T denoting the number of test cases.
Next T lines contain the integer N.

Output Format:

For every test case print the required output.

Constraints:

\(1 ≤ T ≤ 100\)
1 \(≤\) N \(≤\) \(10\)9

Problem Setter - Harsh Jain

SAMPLE INPUT
4
4
8
7
5
SAMPLE OUTPUT
1
1
3
2
Explanation

For 8, you need to add 1 only once at the starting. It will double to 2, then to 4, then to 8.

For 5, you need to add 1 at the beginning, it will double to 2, then to 4, then you will have to add 1 again to make it 5. So, answer is 2.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

通知
View All Notifications

?