B. [ZJ-001] 冰雹猜想/角谷猜想

    传统题 100ms 10MiB

[ZJ-001] 冰雹猜想/角谷猜想

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Background

The Collatz Conjecture states that:

For any positive integer xx:

  • If it's odd, multiply it by 33 and add 11, i.e.: xx×3+1x \rarr x \times 3 + 1;

  • If it's even, divide it by 22, i.e.: xx2x \rarr \dfrac{x}{2}.

By repeating these operations, the number will eventually reach 11 and fall into the 142141 \rarr 4 \rarr 2 \rarr 1 \rarr 4 \rarr \cdots loop.

Description

Now, write a program to calculate how many operations are needed for a positive integer xx to transform into 11.

Input

A single line containing the positive integer xx to be processed.

Output

A non-negative integer ss, representing the number of operations required.

7
16
8
3

Hint

【Data Scale and Convention】

For 100%100\% of the data, 1x2×1061 \leq x \leq 2 \times 10^6.

超绝骗分赛

未参加
状态
已结束
规则
IOI
题目
4
开始于
2026-6-25 12:00
结束于
2026-6-29 12:00
持续时间
96 小时
主持人
参赛人数
6