mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
brute force method for Euler# 09
This commit is contained in:
parent
90e6ee0771
commit
30bc9a201f
18
project_euler/Problem 09/sol1.c
Normal file
18
project_euler/Problem 09/sol1.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
for (int a = 1; a < 300; a++)
|
||||
for (int b = a+1; b < 400; b++)
|
||||
for (int c = b+1; c < 500; c++)
|
||||
{
|
||||
if (a * a + b * b == c * c)
|
||||
if (a + b + c == 1000)
|
||||
{
|
||||
printf("%d x %d x %d = %ld\n", a, b, c, (long int) a*b*c);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user