题解 | 水仙花数 py测区域间

水仙花数

https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703

import sys

for line in sys.stdin:
    m,n=map(int,line.strip().split())
    a=[]
    for b in range(m,n+1):
        hundreds=b//100
        tens=(b//10)%10
        units=b%10
        if hundreds ** 3 + tens ** 3 + units ** 3 == b:
            a.append(str(b))
    print(' '.join(a)if a else 'no')

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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