#CCBCHMOT0000006. Lặp nhân đôi có giới hạn (Doubling to Reach a Limit)
Lặp nhân đôi có giới hạn (Doubling to Reach a Limit)
Doubling to Reach a Limit
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Start with x=1; each operation doubles x. Given positive N, find the smallest number of operations needed until x >= N. If N=1, the answer is zero.
Input
One positive integer N.
Output
Print the minimum number of doublings.
Subtasks
- Subtask 1 (20%): 1 <= N <= 4.
- Subtask 2 (30%): 1 <= N <= 1000.
- Subtask 3 (50%): 1 <= N <= 1000000000.
Examples
Example 1
Input
17
Output
5
Explanation
The sequence is 1,2,4,8,16,32; the fifth operation first reaches 17.
Example 2
Input
1
Output
0
Explanation
The initial value already meets the target.