F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Cut The Wire

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 2573    Accepted Submission(s): 983


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.
 

Sample Input
2 12 60
 

Sample Output
10 50
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 05:16:44, Gzip enabled