atcoder#ABC116B. [ABC116B] Collatz Problem
[ABC116B] Collatz Problem
Score : points
Problem Statement
A sequence is determined as follows:
- The first term is given as input.
- Let be the following function: if is even, and if is odd.
- when , and when .
Find the minimum integer that satisfies the following condition:
- There exists an integer such that .
Constraints
- All values in input are integers.
- It is guaranteed that all elements in and the minimum that satisfies the condition are at most .
Input
Input is given from Standard Input in the following format:
Output
Print the minimum integer that satisfies the condition.
8
5
. As , the answer is .
7
18
$a=\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\}$.
54
114