Count the weights

5

1 votes
Problem

Shortest problem statement ever.
You are given a weight w(of W kg) in integer, and you are asked to find the minimum no. of weights you should have to measure all the weights from 1 kgto w kg(both included).


Input
1st line is the number of test cases T.
Next T lines contains a single integer, weight W.


Output
Print T lines of output denoting the number of weights required.

Constraints-
0 <= T <= 10^9
0 <= w <= 10^9

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Case 1 - Since the weight is 0, so the no of weights required will also be 0.

Case 2 - We will need 3 weights of 1, 1, 3. Now to measure 1Kg, we have weight 1. To measure 2 kg, we have 1, 1. To measure 3 kg we have 3. To measure 4 kg we've 3, 1 and to measure 5 kg, we have 1,1, 3.

Case 3 - We will need 4 weights of 1, 2, 3, 4. Weights till 4 kg can be measured in usual way. For 5 kg we will need 4, 1. For 6 kg, we will need 4, 2. For 7 kgs, we will need 4, 3. For 8 kgs we will need 4, 3, 1. For 9kgs, we will need 4, 3, 2. For 10 kgs we'll need all the weights together.

Editor Image

?