Eularproject 39: The number of right triangle to determine the perimeter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.