'commit'
This commit is contained in:
20
TangDou/LuoGuBook/P5727_1.cpp
Normal file
20
TangDou/LuoGuBook/P5727_1.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 210;
|
||||
int a[N], idx;
|
||||
int n;
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
while (n > 1) {
|
||||
a[idx++] = n;
|
||||
if (n & 1)
|
||||
n = n * 3 + 1;
|
||||
else
|
||||
n = n >> 1;
|
||||
}
|
||||
a[idx] = 1;
|
||||
for (int i = idx; i >= 0; i--) printf("%d ", a[i]);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user