2020-06-06 00:20:25 +08:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief [Problem 9](https://projecteuler.net/problem=9) solution - A naive
|
|
|
|
* implementation
|
2020-06-07 02:51:49 +08:00
|
|
|
* \author [Krishna Vedala](https://github.com/kvedala)
|
2020-06-06 00:20:25 +08:00
|
|
|
*/
|
2020-03-30 09:20:49 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2020-06-06 00:20:25 +08:00
|
|
|
/** Main function */
|
2020-03-30 09:20:49 +08:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
for (int a = 1; a < 300; a++)
|
2020-05-30 04:23:24 +08:00
|
|
|
for (int b = a + 1; b < 400; b++)
|
|
|
|
for (int c = b + 1; c < 500; c++)
|
2020-03-30 09:20:49 +08:00
|
|
|
{
|
|
|
|
if (a * a + b * b == c * c)
|
|
|
|
if (a + b + c == 1000)
|
|
|
|
{
|
2020-05-30 04:23:24 +08:00
|
|
|
printf("%d x %d x %d = %ld\n", a, b, c,
|
|
|
|
(long int)a * b * c);
|
2020-03-30 09:20:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2020-06-07 02:51:49 +08:00
|
|
|
}
|