File: euler9.c

package info (click to toggle)
qbe 1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,004 kB
  • sloc: ansic: 13,368; yacc: 843; ml: 466; sh: 379; python: 232; makefile: 100
file content (27 lines) | stat: -rw-r--r-- 340 bytes parent folder | download
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
#include <stdio.h>

main()
{
	int i;
	int a;
	int b;
	int c;
	int d;
	
	for (a = 1; a < 1000; a++) {
		for (b = a + 1; b < 1000; b++) {
			d = a*a + b*b;
			for (i = 0; i < 1000; i++) {
				if (i * i == d) {
					c = i;
					if (b < c && a+b+c == 1000) {
						printf("%d\n", a*b*c);
						return 0;
					}
					break;
				}
			}
		}
	}
}