CT106

Integer Right Triangles

MediumAcceptance: 0.0%

If p is the perimeter of a right triangle with integer sides {a, b, c}, exactly one solution exists for p = 12: {3, 4, 5}. Given p_max, find which value of p <= p_max has the most solutions.

Example 1:

Input: 12
Output: 12

Example 2:

Input: 1000
Output: 840

Example 3:

Input: 120
Output: 120

Constraints:

12 <= p_max <= 1000

Tags:

math pythagorean optimization
Loading...
Test Cases:No test cases
No test cases available.