Jump Hide-and-Seek
Time limit1sMemory limit512 MB
Starting at 0, each jump doubles the previous one (1, 2, 4, ...); find the minimum number of jumps to land exactly on K, or report -1.
- Level
Medium6 of 10
- Topics
- Math, Greedy, Bit manipulation, Brute force
- Solved
- No attempts yet
Problem
Hyunwook is playing hide-and-seek with his older brother. Hyunwook is currently at point , and his brother is at point ().
Hyunwook likes jumping, so he always moves by jumping. His first jump covers a distance of . He gets more excited with each jump, so every jump covers twice the distance of the previous jump.
Given the position of Hyunwook's brother, find the minimum number of jumps Hyunwook needs to reach him.
Input
The first line gives the position of Hyunwook's brother ().
Output
On the first line, print the minimum number of jumps Hyunwook needs to reach his brother's position. If there is no way to reach it, print .