我已經有先建表了
但仍出現超時
有人可以幫忙解惑嗎
import sys
#建表
ans=[]
for i in range(1,1000000):
line=str(i)
s=0
for j in range(len(line)):
s+=int(line[j])**len(line)
if s==i:
ans.append(i)
l=len(ans)
for line in sys.stdin:
a,b=map(int,line.split())
count=0
for j in range(l):
if a<= ans[j] <=b:
print("{0} ".format(ans[j]),end="")
count+=1
elif ans[j]>b:
break
if count==0:
print("none")
else:
print()