B. 奇怪的算法

    Type: Default 1000ms 256MiB

奇怪的算法

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.

题目背景

翻译自 CSES-1068 题。

题目描述

考虑如下算法:输入一个正整数 nn。如果 nn 是偶数,将其除以 22,如果 nn 是奇数,将其乘以 33 再加上 11。算法重复这个过程,直到 nn11

例如,当 n=3n=3 时,其变化序列为:$3\rightarrow 10 \rightarrow 5 \rightarrow 16 \rightarrow 8 \rightarrow 4 \rightarrow 2 \rightarrow 1$。

你的任务对给定的 nn 模拟执行如上算法。

输入格式

输入一个正整数 nn

输出格式

输出一行若干个整数,表示算法的执行序列。

样例

3
3 10 5 16 8 4 2 1

说明/提示

1n1061\le n \le 10^6

系统小测试

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2025-9-10 19:30
End at
2025-9-10 21:30
Duration
2 hour(s)
Host
Partic.
1