题目连接:https://www.luogu.com.cn/problem/P5727
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> v;
int main() {
int n; cin >> n;
v.push_back(n);
while (n > 1) {
if (n & 1) n = n * 3 + 1, v.push_back(n);
else n = n / 2, v.push_back(n);
}
reverse(v.begin(), v.end());
for (auto it : v) cout << it << " ";
return 0;
}