PivotOJ

Simple Collatz Sequence

시간 제한: 1000ms메모리 제한: 512MB출처: ICPC Greater New York 2019BOJ 17869

문제

The Simple Collatz Sequence (SCS) starting at an integer n, is defined by the formula:

S(k) = (k/2 if k is even, else (k+1))

The sequence is then n, S(n), S(S(n)), … until the value first reaches 1.

For example, starting at 11, we have:

11 -> 12 -> 6 -> 3 -> 4 -> 2 ->1

The sequence always ends at 1. (Fun Fact: The Hard Collatz Sequence sends odd k to 3*k+1. It is unknown whether that sequence always ends at 1.)

Let A(n) = number of steps in the SCS starting at n. For example, A(11) = 6. Write a program which computes A(n) for a given input n.

입력

Input consists of a single line which contains a positive decimal integer, n, which starts the sequence. n will fit in a 32-bit unsigned integer.

출력

The output consists of a single line that contains the value of A(n), the number of steps in the SCS starting at n.

예제

예제 1

입력
11
출력
6

예제 2

입력
123456789
출력
39
코드를 제출하려면 로그인하세요.