如果你是來抄的,請先了解過程
min,max=map(int,input().split())
w=''
for i in range(min,max+1):
t=list(str(i))
n=len(t)
p=0
for j in t:
p+=int(j)**n
if p==i:
w+=' '+str(p)
print(w[1:len(w)+1])
if len(w)==0:
print('none')
Python有更快的寫法?當然有的!給你參考:
一行解
print((lambda o:"none" if len(o)==0 else " ".join(o))((lambda l:[str(i) for i in range(int(l[0]),int(l[1])+1) if sum([int(c)**len(str(i)) for c in str(i)])==i])(input().split())))