Huadian North Wind Blows
Key laboratory of cognitive computing and application, Tianjin University
Completion Date: 2015/7/30
Integer Right Triangles
Problem 39
If P is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there be exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
for which value of p≤1000, is the number of solutions maximised?
Answer:
840
Completed on Thu, 2015, 04:51
Go to the "thread for Problem" in the forum.
Nature of utilization
< Span class= "Mrow" id= "mathjax-span-1710" >b + c = l a
C?b= a Span style= "Display:inline-block; width:0px; Height:2.456em; " > 2 l? a
a <= b < C
a + b > Span class= "Mi" id= "mathjax-span-1745" style= "font-family:mathjax_math-italic; Padding-left:0.269em; " >c
One of the second properties is divisible a Can greatly reduce the computational time
__author__ =' Zhengyi ' def isrighttriangle(ABC):A2=pow (abc[0],2) B2=pow (abc[1],2) C2=pow (abc[2],2) TEMP=A2+B2-C2iftemp==0:return 1 Else:iftemp<0:return 0 Else:return-1 def Count(perimeter):Count=0 forAinchRange1, perimeter//3):ifPow (A,2)% (perimeter-a)! =0 orPow (A,2)//(PERIMETER-A) >=a:Continue forBinchRange (Max (perimeter//2-a,a), perimeter//2): Temp=isrighttriangle ([A,b,perimeter-a-b])iftemp==-1: Break Else: count+=tempreturnCountcount=0p=0 forIinchRange1,1001): Temp=count (i)ifTemp>count:p=i Count=tempprint (P)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Eularproject 39: The number of right triangle to determine the perimeter