UVA 10112 (暑假-几何- D - Myacm Triangles)

#include <cstdio>
#include <cmath>

int main() {
	int n;
	while (scanf("%d", &n) && n) {
		int max = 0;
		int arr[20][5];
		int crr[8000][4];
		getchar();
		for (int i = 0; i < n; i++) {
			scanf("%c%d%d\n", &arr[i][0], &arr[i][1], &arr[i][2]);
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				for (int k = j+1; k < n; k++) {
					int kong = 0;
					crr[count][3] = ((arr[k][2] - arr[i][2]) * (arr[j][1] - arr[i][1]) - (arr[j][2] - arr[i][2])*(arr[k][1] - arr[i][1]));
					crr[count][3] = fabs(crr[count][3]);
					for (int l = 0; l < n; l++) {
						if (l != i && l != j && l != k) {
							int	s1 = ((arr[l][2] - arr[i][2]) * (arr[j][1] - arr[i][1]) - (arr[j][2] - arr[i][2])*(arr[l][1] - arr[i][1]));
							int s2 = ((arr[k][2] - arr[i][2]) * (arr[l][1] - arr[i][1]) - (arr[l][2] - arr[i][2])*(arr[k][1] - arr[i][1]));
							int s3 = ((arr[k][2] - arr[l][2]) * (arr[j][1] - arr[l][1]) - (arr[j][2] - arr[l][2])*(arr[k][1] - arr[l][1]));
							s1 = fabs(s1);
							s2 = fabs(s2);
							s3 = fabs(s3);
							if ( s1 + s2 + s3 == crr[count][3]) {
								kong = 1;
								break;
							}
						}
					}
					if (!kong) {
						if (crr[count][3]>max) {
							max = crr[count][3];
							crr[count][0] = i;
							crr[count][1] = j;
							crr[count][2] = k;
							count++;
						}
					}
				}
			}
		}
		printf("%c%c%c\n", crr[count-1][0]+'A', crr[count-1][1]+'A', crr[count-1][2]+'A');
	}
return 0;
}

你可能感兴趣的:(UVA 10112 (暑假-几何- D - Myacm Triangles))