题目描述
A sequence a={a1,a2,a3,......} is determined as follows:
-
The first term s is given as input.
-
Let f(n) be the following function: f(n)=n/2 if n is even, and f(n)=3n+1 if n is odd.
-
ai=s when i=1, and ai=f(ai−1) when i>1.
Find the minimum integer m that satisfies the following condition:
- There exists an integer n such that am=an(m>n).
一个序列 a={a1,a2,a3,......} 确定如下:
-
输入第一个项 s 。
-
设 f(n) 为以下函数:如果 n 是偶数,则 f(n)=n/2 ;如果 n 是奇数,则 f(n)=3n+1 。
-
当 i=1 时为 ai=s ,当 i>1 时为 ai=f(ai−1) 。
求满足以下条件的最小整数 m :
- 存在一个整数 n ,使得 am=an(m>n) .
输入格式
输入内容按以下格式标准输入:
s
输出格式
打印满足条件的最小整数 m 。
样例 #1
样例输入 #1
8
样例输出 #1
5
样例 #2
样例输入 #2
7
样例输出 #2
18
样例 #3
样例输入 #3
54
样例输出 #3
114
说明
数据规模与约定
- 1≤s≤100
- 输入值均为整数。
- 保证 a 中的所有元素以及满足条件的最小值 m 最多为 1000000 。
样例 1 解释
a={8,4,2,1,4,2,1,4,2,1,......} .如 a5=a2 ,答案为 5 。
样例 2 解释
$a=\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\}$ .