summaryrefslogtreecommitdiff
path: root/039.c
blob: 202df6c6d3f82bb8c2c9fd72d44c80cad969df50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

int solutions(int p)
{
	int solution = 0;
	int a, b, c;

	for(a=0; a<p/2; a++)
		for(b=0; b<p-a; b++)
		{
			c = p - a - b;
			if(a*a + b*b == c*c)
				solution++;
		}
	return solution;
}

int main()
{
	int max_solutions = 0;
	int max_p = 0;
	int p;

	for(p=3; p<=1000; p++)
	{
		int n = solutions(p);
		if(n > max_solutions)
		{
			max_solutions = n;
			max_p = p;
		}
	}

	printf("%d\n", max_p);

	return 0;
}