思路:暴力解
C#
#include<stdio.h>
#include<math.h>
int main(){
int a=1,b=1,c=1;
long mul = 0;
for (a = 1; a < 1000; a++){
for(b = a;b <= (1000-a) ;b++){
for(c = b;c <= (1000-a-b);c++){
if((a*a+b*b== c*c) && (a+b+c==1000))
//printf("%d %d %d\n",a,b,c);
mul = a*b*c;
}
}
}
printf("%d",mul);
return 0;
}
JAVA
package exercise;
public class _特殊毕达哥拉斯三元组 {
public static void main(String[] args) {
for(int a=1;a<1000;a++) {
for(int b=1;b<1000;b++) {
for(int c=1;c<1000;c++){
if((a<b)&&(b<c)&&((a*a+b*b)==c*c)&&((a+b+c)==1000)) {
System.out.println(a*b*c);
}
}
}
}
}
}
结果:31875000