Pro.ID22314 TitleCollatz Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22314 AC13 Submit33 Ratio39.39% 时间&空间限制描述In the process to solve the Collatz conjecture, better known as the 3n + 1 problem, Carl created a physical model with wood and ropes. A wooden bar contains a hole for every natural number from 1 to infinity from left to right. For every even number m there is a rope connecting the m-th hole with hole m/2 . For every odd number n there is a rope connecting the nth hole with hole 3n + 1. For an important conference where Carl plans to elaborate on his results, he wants to bring his structure, but it is too large to fit in his bag. So he decided to saw off the part of the bar containing the first N holes only. How many ropes will he need to cut? 输入The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format: One line with an integer N, satisfying 0 ≤ N ≤ 109. 输出Description In the process to solve the Collatz conjecture, better known as the 3n + 1 problem, Carl created a physical model with wood and ropes. A wooden bar contains a hole for every natural number from 1 to infinity from left to right. For every even number m there is a rope connecting the m-th hole with hole m/2 . For every odd number n there is a rope connecting the nth hole with hole 3n + 1. For an important conference where Carl plans to elaborate on his results, he wants to bring his structure, but it is too large to fit in his bag. So he decided to saw off the part of the bar containing the first N holes only. How many ropes will he need to cut? Input The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format: One line with an integer N, satisfying 0 ≤ N ≤ 109. Output For every test case in the input, the output should contain a single number, on a single line: the number of ropes that need to be cut. Sample Input 3 Sample Output 10 Source 样例输入3 样例输出10 作者 |