题目大意:给定圆心在原点的一个圆内的 2 * n 个整点,求由 AX + BY = 0(A, B均为 -500 到 500 的整数)确定的一条直线,使得直线两边的点一样多,点不允许在直线上。
#include <cstdio> int main() { int n; while (scanf("%d", &n), n) { int cherry[100][2]; for (int i = 0; i < 2 * n; i++) scanf("%d%d", &cherry[i][0], &cherry[i][1]); for (int A = -100; A <= 100; A++) for (int B = -100; B <= 100; B++) { int count = 0, i = -1; while (++i < 2 * n) { if (A * cherry[i][0] + B * cherry[i][1] == 0 || count > n || i - count > n) break; if (A * cherry[i][0] + B * cherry[i][1] > 0) count++; } if (i == 2 * n && count == n) printf("%d %d\n", A, B), A = 101, B = 101; } } return 0; }