这题很黄很暴力/* coder: ACboy date: 2010-3-17 result: AC desecription: UVa 10167 - Birthday Cake */ #include <iostream> using namespace std; struct TPoint { int x; int y; }; TPoint data[110]; void findAns(int n){ srand(time(NULL)); int A, B; while (1) { A = -500 + (rand() % 1001); B = -500 + (rand() % 1001); int count1 = 0; int count2 = 0; for (int i = 0; i < 2 * n; ++i) { if (A * data[i].x + B * data[i].y > 0) { count1++; } else if (A * data[i].x + B * data[i].y < 0) { count2++; } } if (count1 == n && count2 == n) { break; } } cout << A << " " << B << endl; } int main() { int n; #ifndef ONLINE_JUDGE freopen("10167.txt", "r", stdin); #endif while (cin >> n) { if (n == 0) break; int i; for (i = 0; i < 2 * n; ++i) { cin >> data[i].x >> data[i].y; } findAns(n); } }