#C. 3X+1猜想

    Type: Default 1000ms 256MiB

3X+1猜想

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

Special for beginners, ^_^

Description

在数学上有个这样的猜想:任何一个大于1正整数x,经过下面的变换最终都能变为1,变换规则是:如果x是奇数,将它乘以3再加1,即x变为3∗x+1,如果x是偶数,将它除以2,即x变为x/2;继续这样变换,直到变为1为止。

如:x=22,则变换过程如下:22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1。对于给定的N,我们把显示出来的数的个数称为x的链长,例如22的链长为16。

现在你的任务是编写一个程序B.cpp。读入一个正整数x,输出它的链长。

Format

Input

输入一个正整数x。

Output

答案

Samples

输入1

4

输出1

3

输入2

5

输出2

6

Limitation

10组数据, x30x \le 30

另外10组数据 x106 x \le 10^6

初一上学期期中考试机试(3班)

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2022-11-7 8:45
End at
2022-11-7 10:45
Duration
2 hour(s)
Host
Partic.
47