研究python ing 什么都不懂的...
刷水题练python...
#Fiename:pe44.py
import math
arr = [0 for row in range(10000)]
def check(x):
i=int(math.sqrt(x*0.2/3))-1
while (i*(i*3-1))/2<x:
i=i+1
if i*(i*3-1)/2==x:
return 1
return 0
for i in range (1,3000):
arr[i]=i*(i*3-1)/2
Max=0xfffffff
for i in range (1,3000):
for j in range(i+1,3000):
if check(arr[i]+arr[j])==1 and check(arr[j]-arr[i])==1 and arr[j]-arr[i]<Max:
Max=arr[j]-arr[i]
print Max
posted on 2010-08-21 22:24
ccyy 阅读(272)
评论(0) 编辑 收藏 引用