32 lines
619 B
C
32 lines
619 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
// This is definitely a silly and innefficient way to do this
|
|
// But... everything is fast for small n :^)
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
for (int a = 1; a < 1000; a++)
|
|
{
|
|
for (int b = 1; b < 1000; b++)
|
|
{
|
|
for (int c = 1; c < 1000; c++)
|
|
{
|
|
if (a + b + c != 1000)
|
|
continue;
|
|
if (a*a + b*b != c*c)
|
|
continue;
|
|
printf("Solution found:\n");
|
|
printf("a = %d\n", a);
|
|
printf("b = %d\n", b);
|
|
printf("c = %d\n", c);
|
|
printf("Product of a, b, and c: %d\n", a*b*c);
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
}
|
|
}
|
|
printf("Solution not found :(\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|