/*
http://projecteuler.net/problem=9
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.
*/
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int a = 1;
int b = 0;
for(a = 1; a != 334; ++a)
{
int t = 1000 * (500 - a);
b = t / ( 1000 - a );
if ( b * ( 1000 - a ) == t )
{
break;
}
}
int c = 1000 - a - b;
cout << "a=" << a << ", b=" << b << ", c=" << 1000 - a - b << endl;
cout << "a* b * c=" << a* b * c;
return 0;
}