题解 | #小红的好数#(Python3)
小红的好数
https://www.nowcoder.com/practice/de234d0d61d549c6a436e9509dbeea11
def check(s): chk = set(s) return len(chk)==len(s) def func(k): ans = [] for i in range(99999, 9999, -1): s = str(i) if(check(s)): ans.append(s) for i in range(9999, 999, -1): s = '0' + str(i) if(check(s)): ans.append(s) # 三位数的不用看了,因为补了2个0,不会是好数 return ans while True: try: k = int(input()) result = func(k) print(result[k-1]) except EOFError: break#15天刷题#