https://pintia.cn/problem-sets/994805260223102976/problems
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX 10000
using namespace std;
bool num[3 * MAX + 1];
int main(void) {
int n, data;
vector<int> v;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> data;
v.push_back(data);
while (data != 1) {
if (data % 2)
data = (3 * data + 1) / 2;
else
data /= 2;
num[data] = true;
}
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
int flag = 0;
for (int i = 0; i < v.size(); i++)
if (num[v[i]] == false) {
if (flag)
cout << " ";
cout << v[i];
flag = 1;
}
}
####代码3
应该是 data =(data * 3 + 1)/2;
###部分正确,未过原因未知