Cut The Wire

TimeLimit:1000MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
In the country of Infinity , there is a strange road. This road only has a starting point, but no end. Since this road is infinite, there are also countless street lights. The street lights are numbered from $1$(the starting point) to infinity. The street lights are connected by wires under a strange law:

For a street light $x$,


  • if $x$ is even, then $x$ is connected with $\frac{x}{2}$ by a wire;


  • if $x$ is odd, then $x$ and $3x + 1$ is connected by a wire.



Now Kris is standing in the middle of street light $n$ and $n + 1$, and he is able to cut all wires passing by. That is, he will cut all wires connecting street lights $a$ and $b$ satisfying $a \leq n$ and $b > n$.

Now he wonders, how many wires he will cut. Please help him calculate.
Input
This problem contains multiple test cases.

The first line contains an integer $T(1 \leq T \leq 10 ^ 5)$ indicating the number of test cases.

The next $T$ lines each contains one integer $n(1 \leq n \leq 10 ^ 9)$.
Output
For each test case, output one line of one integer indicating the answer.
SampleInput
2
12
60
SampleOutput
10
50
Submit
题目统计信息详细
总AC数6
通过人数6
尝试人数6
总提交量7
AC率85.71%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: