2013-04-17 14:34:39 +08:00

39 lines
693 B
Python

def cuberoot(x):
sqr = int(x ** 0.5)
return rootiter(x, sqr)
def rootiter(x, pre):
cur = pre - float(pre ** 3 - x) / (3 * pre ** 2)
if abs(cur - pre) <= 0.001:
return int(cur)
else:
return rootiter(x, cur)
def breaknum(x):
out = []
while x != 0:
out.append(str(x % 10))
x /= 10
return out
def main():
dic = {}
i = 1
while 1:
tmplis = breaknum(i ** 3)
tmplis.sort()
tmp = ''.join(tmplis)
if dic.has_key(tmp):
dic.get(tmp).append(i)
if len(dic.get(tmp)) == 5:
return dic.get(tmp)
else:
dic.update({tmp:[i]})
i += 1
xx = main()
print xx
for i in xx:
print i ** 3