Special Pythagorean triplet
Problem 9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a
2 +
b
2 =
c
2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
这道题的输入比较小,直接暴力的方法,循环去做,取出满足条件的即可
for i in range(1,1000 // 3 + 1):
for j in range(i+1,(1000 - i) // 2 + 1):
if i **2 + j ** 2 == (1000 - i - j ) ** 2:
print(i * j * (1000 - i - j))