- 积分
- 1
- 注册时间
- 2010-6-26
- 仿真币
-
- 最后登录
- 1970-1-1
|
本帖最后由 upc1984 于 2010-9-27 10:28 编辑
原帖http://forum.simwe.com/thread-911102-1-1.htmlMathematica 解法用matlab实现
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?
120可以写为三组勾股数(整数)之和,分别是{20,48,52}, {24,45,51}, {30,40,50}。要求在不超过1000的数字中求出可以写为最多组勾股数之和的数。-
- clear;clc;close all;
- t=1;
- for i=1:500
- for j=i:1000
- for k=j:1000
- if i^2+j^2==k^2&&i+j+k<=1000
- a(t,:)=[i,j,k];
- t=t+1;
- end
- end
- end
- end
- [m,n]=mode(sum(a,2))
- [code]Elapsed time is 36.998713 seconds.
复制代码
[/code]以上是我的方法,效率不高,还有其他的好的办法么,请多指导!
|
|
评分
-
1
查看全部评分
-
|