Type: Default 1000ms 256MiB

Collatz序列

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.

Description

奶牛们正在玩一个有趣的数字游戏。

其中的一头牛选出一个小于32000的正整数N。奶牛们就开始下赌注这个数的Collatz序列的长度是否会超过一个数比如100。

Collatz序列是这样计算的:从一个整数C开始,

如果C为1,序列结束。否则

如果C为偶数,就把它平分产生一个新的C/2

如果C为奇数,就把它替换为3×\times C+1

照这个规则继续下去直到结束。 考虑以10开始的Collatz序列: 10,5,16,8,4,2,1

它的长度是7。

请你帮助其中的一头牛作弊:给定一个N,计算出它的Collatz序列的长度。

Input Format

单独的一行,一个整数N。

Output Format

单独的一行,一个整数表示以N开头的Collatz序列的长度。

Sample

input

10

output

7

Hint

保证N32000N \leq 32000

时间限制:1s1 \text {s}

空间限制:256MB256 \text {MB}

20200910-基础递归训练

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
10
Start at
2020-9-13 15:29
End at
2020-10-1 15:29
Duration
432 hour(s)
Host
Partic.
18