#P15046. [UOI 2022 II Stage] 魔法鞋

    ID: 16975 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>模拟数学2022进制UOI(乌克兰)

[UOI 2022 II Stage] 魔法鞋

Problem Description

Friends of Cossack Moustache received that secret letter. It turned out that inside there was a blueprint for a pair of ancient magic shoes. These magic shoes allow the wearer to accelerate to an amazing speed. The wearer’s initial speed is 11 meter per second.

If the current speed of the person wearing the magic shoes is aa meters per second, then she can cast one of the following two spells:

  • Increase her speed by aa meters per second.
  • Increase her speed by a+1a+1 meters per second.

What is the minimum number of spells she needs to cast to increase her speed exactly to kk meters per second?

Input Format

The first line contains an integer kk (1≤k≤10181 \leq k \leq 10^{18}), the target speed to reach. It is guaranteed that the given speed can be reached in a finite number of steps.

Output Format

Output one number, the minimum number of spells needed to reach the given speed.

1
0
2
1
10
3
10000
13

Hint

In the first sample, the initial speed is already 11, so no spells are needed.

In the second sample, you can use the first spell, so the speed increases by 11 meter per second and becomes exactly 22 meters per second.

In the third sample, you can use the first spell, then the second spell, then the first spell. The speed changes as follows: 1→2→5→101 \rightarrow 2 \rightarrow 5 \rightarrow 10. It can be proven that the number of spells needed to reach this speed cannot be smaller.

Translated by ChatGPT 5