Just like pickle
Time limit1sMemory limit1024 MB
Given x, find the fewest jumps of length 2^k, left or right, that take the grasshopper from 0 to x.
- Level
Medium5 of 10
- Topics
- Bit manipulation, Math
- Solved
- No attempts yet
Statement
Grasshopper is standing on a line at a point with coordinate . In one turn it can choose any non-negative integer and jump to the left or to the right by the distance .
Find the minimum number of turns the grasshopper has to make to move from the point with coordinate to the point with coordinate .
Input
The first line contains a single integer , the number of test cases ().
Each test case consists of one line containing a single integer , the coordinate of the target point ().
Output
For each test case, output a single integer: the minimum number of turns the grasshopper has to make.