归1(Weird Algorithm)
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
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:
3→10→5→16→8→4→2→1
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
- 1 ≤ n ≤ 10^6
- Time limit: 1.00 s
- Memory limit: 512 MB
Introductory Problems
- Status
- Done
- Rule
- Ledo
- Problem
- 9
- Start at
- 2024-8-13 9:00
- End at
- 2024-8-13 12:18
- Duration
- 3.3 hour(s)
- Host
- Partic.
- 4