题解 | #水仙花数#

水仙花数

http://www.nowcoder.com/practice/11c9f023a9f84418a15b48792a5f7c70

while True:
    try:
        m,n=map(int,input().split())
        k=[]
        for i in range(m,n+1):
            i=str(i)
            a=int(i[0])
            b=int(i[1])
            c=int(i[2])
            i=int(i)
            if a**3+b**3+c**3==i:
                    k.append(i)
            else:
                continue
        if len(k)==0:
            print('no')
        else:
            for i in k:
                print(i,end=' ')
            print()
    except:
        break

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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