Problem 9
25 January 2002
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^(2) + b^(2) = c^(2)
For example, 3^(2) + 4^(2) = 9 + 16 = 25 = 5^(2).
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
Answer:
31875000
#include
int main(void)
{
int i,j;
for(i=1;i<=500;i++)
for(j=1;j<500;j++)
{
if(i*i+j*j==(1000-i-j)*(1000-i-j))
printf("%d\n",i*j*(1000-i-j));
}
return 0;
}
Test
13 年前
0 评论:
发表评论