問題一覧 > 通常問題

No.887 Collatz

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 459
作問者 : trineutron / テスター : yuki2006
お気に入りにしたユーザー ProblemId : 3131 / 自分の提出
問題文最終更新日: 2022-04-26 01:53:08
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 224 (順位表) の他の問題:

Problem Statement

Let $n_i (i \ge 0)$ be positive integers. Consider the sequence $\{n_i\}$ defined so that, if $n_i$ is even, $n_{i+1}=n_i/2$, and if it is odd, $n_{i+1}=3n_i+1$. Let $i_1$ be the smallest $i$ satisfying $n_i=1$. Let $n_{max}$ be the maximum value of $n_i (0 \le i \le i_1)$. Find $i_1$ and $n_{max}$.

Input

$n_0$

$n_0$ is an integer.
$1 \le n_0 \le 2^{16}$
Under these constraints, $i_1 \lt 400, n_{max} \lt 2^{30}$ holds.

Output

Print $i_1$ and $n_{max}$, separated by a newline. Print a newline at the end.

Sample

Sample 1
Input
3
Output
7
16

The sequence is 3, 10, 5, 16, 8, 4, 2, 1.

Sample 2
Input
27
Output
111
9232

Sample 3
Input
10000
Output
29
10000

$n_0$ may be $n_{max}$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。