传说存在唯一一组勾股数,三个数的和是1000,那么它的积是多少呢?
def judge(a,b,c):
if a+b<=c or b+c<=a or a+c<=b:
return 0
if a*a+b*b==c*c or b*b+c*c==a*a or a*a+c*c==b*b:
return 1
result=0
for i in range(1,1000):
for j in range(1,1000-i):
k=1000-i-j
if judge(i,j,k):
result=i*j*k
print(result)
时间: 2024-11-17 09:47:52