fork download
  1. #include <iostream>
  2.  
  3. //problem 9:
  4. //find the product of a + b + c = 1000 where a < b < c && a^2 + b^2 = c^2
  5.  
  6.  
  7. int main()
  8. {
  9. int a , b , c;
  10.  
  11. for( int c = 997; c > 3; --c )
  12. {
  13. for( int b = 1000 - c - 1; b > 1; --b )
  14. {
  15. a = 1000 - b - c;
  16. if( a * a + b * b == c * c && b > a )
  17. {
  18. std::cout << "Result: " << a * b * c << std::endl;
  19. }
  20. }
  21. }
  22. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Result: 31875000