Logo
(追記) (追記ここまで)

5393번 - Collatz 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB79323019332.546%

문제

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 mth 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.

출력

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.

제한

예제 입력 1

3
12
240
3600

예제 출력 1

10
200
3000

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2010 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /