赞
踩
给定长度为 n n n 的数组 a a a,按照以下要求进行排序:
import sys sys.setrecursionlimit(1000000) input = lambda:sys.stdin.readline().strip() 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 = " ")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。