解题思路:
注意事项:
参考代码:class number:
def __init__(self, v, c):
self.v = v
self.c = c
def __lt__(self, other):
if self.c != other.c:
return self.c < other.c
return self.v < other.v
def get(x):
res = 0
while x > 0:
t = x % 10
if t == 0 or t == 4 or t == 6 or t == 9:
res += 1
elif t == 8:
res += 2
x //= 10
return res
n = int(input())
a = list(map(int, input().split()))
g = []
for x in a:
g.append(number(x, get(x)))
g.sort()
for x in g:
print(x.v, end = " ")
0.0分
0 人评分