# 观摩了一下 大佬代码的优化
# eval 函数自动将输入转为int
n = eval(input())
s = list(map(int, input().split()))
# 注意深浅拷贝问题
dit = s[:]
print(dit)
for e in s:
while e != 1:
if e % 2 == 0:
e = e // 2
else:
e = (3 * e + 1) // 2
if e in dit: # 如果在e列表中出现过,则说明可以被覆盖,移出去
dit.remove(e)
# 对列表进行逆序排序
dit.sort(reverse=True)
# 返回通过指定字符连接序列中元素后生成的新字符串
print(" ".join(str(i) for i in dit))
1005CallatzPlus
最新推荐文章于 2024-07-28 15:46:11 发布