P27308 [AtCoder] Collatz Problem
提高+
题目描述

Problem Description

For an integer \( X \), the value \( f(X) \) is defined as follows:

  • When \( X \geq 10^{16} \), \( f(X) = 0 \)
  • When \( X \leq 1 \), \( f(X) = 0 \)
  • When \( X \) is even, \( f(X) = f(X/2) + 1 \)
  • Otherwise, \( f(X) = f(3X + 1) + 1 \)

Given an integer \( P \), output any positive integer \( N \) less than or equal to \( 10^{16} \) such that \( f(N) = P \).

Input Format

The input is given from the standard input in the following format:

\( P \)

Output Format

Output an integer \( N \) that satisfies the given condition. If multiple such integers exist, you may output any one of them. It can be shown that such an integer always exists under the given constraints.

Sample Input and Output

Sample Input #1

5

Sample Output #1

5

Sample Input #2

1000

Sample Output #2

1789997546303

Notes/Hints

Constraints

  • \( 0 \leq P \leq 1,000 \)
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5
样例输出
5