Sample Input
2 -20 20 -30 20 -10 -50 10 -5 0
Sample Output
0 1 (-100 21)
错误的测试数据,害人。
CODE:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct node
{
int x, y;
}a[1001];
int cnt;
void get(int n)
{
int i, j, k;
int cnt1, cnt2;
for(i = -100; i <= 100; i++)
{
for(j = -100; j <= 100; j++)
{
cnt1 = cnt2 = 0;
for(k = 0; k < cnt; k++)
{
int ans = a[k].x*i + a[k].y*j;
if(ans > 0)
{
cnt1++;
}
else if(ans < 0)
{
cnt2++;
}
else break;
if(cnt1 == n/2 && cnt2 == n/2)
{
printf("%d %d\n", i, j);
return ;
}
}
}
}
return ;
}
void init()
{
memset(a, 0, sizeof(a));
cnt = 0;
}
int main()
{
int n;
while(~scanf("%d", &n), n)
{
init();
for(int i = 0; i < 2*n; i++)
{
int x, y;
scanf("%d%d", &x, &y);
if(x >= -100 && x <= 100 && y >= -100 && y <= 100)
{
a[cnt].x = x;
a[cnt].y = y;
cnt++;
}
}
get(cnt);
}
return 0;
}