题目如下
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are 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?
代码
clear;clc;close all
[a, b] = meshgrid(1:500);
c = sqrt(a.^2 + b.^2);
idx = c == floor(c) & (a+b+c)< 1000;
mode(a(idx)+b(idx)+c(idx))