水仙数问题的笨解法,大佬们有其他高效的算法吗,至少不要像这样自己输数字判断的
i = 1while i==1:
a = int(input("百位数:"))
b = int(input("十位数:"))
c = int(input("个位数:"))
number = 100*a+10*b+c
if 100< number <1000 and number == a**3 + b**3 +c**3:
print(number)
continue
else:
print("非水仙数")
continue
for i in range(1,10):
for j in range(0,10):
for k in range(0,10):
if i*100+j*10+k==i*i*i+j*j*j+k*k*k:
print(i*100+j*10+k)
print('水仙花数为:',end='')
for i in range(100,1000):
temp = str(i)
if int(i)== int(temp)**3+int(temp)**3+int(temp)**3:
print(i,end='')
页:
[1]