#2387. 归1(Weird Algorithm)

    ID: 2387 Type: FileIO (weird) 1000ms 256MiB Tried: 48 Accepted: 9 Difficulty: 8 Uploaded By: Tags>CSES Introductory Problems

归1(Weird Algorithm)

Description

Consider an algorithm that takes as input a positive integer n. If n is even, thealgorithm divides it by two, and if m is odd, the algorithm multiplies it by threeand adds one. The algorithm repeats this, until m is one. For example, thesequence for n = 3 is as follows:

3105168421

Your task is to simulate the execution of the algorithm for a given value of n.

Format

Input

The only input line contains an integer n.

Output

Print a line that contains all values of n during the algorithm.

Samples

3
3 10 5 16 8 4 2 1

Limitation

  • 1n10^6
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Statistics

Related

In following contests:

Introductory Problems

In following homework:

模拟算法

训练题单一