题解 | #小红的好数#(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天刷题#
全部评论

相关推荐

醉蟀:你不干有的是人干
点赞 评论 收藏
分享
牛客38347925...:9,2学生暑期实习失利开始投小厂,给这群人整自信了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务