题目大意:给你N个点,问分布在Ax+By=0这条线的两边(不能在线上)时,A和B的范围为-500到500,A和B的值分别是多少

解题思路:枚举A和B,从-500到500

#include<cstdio>

struct code{
	int x;
	int y;
};

int main() {
	int N, test,a,b,mark,num;
	code p[1000];
	while(scanf("%d", &N) && N) {
		for(int i = 0; i < 2 *N ;i++) {
			scanf("%d %d",&(p[i].x), &(p[i].y));	
		}
		mark = 0;
		for( a = -500; a <= 500; a++)  {
			for( b = -500; b <= 500; b++) {
				if(a == 0 && b == 0)
					continue;
				num = 0;

				for(int i = 0; i < 2 *N; i++) {
					if((a*p[i].x) + (b * p[i].y) > 0) num++;
					if((a*p[i].x) + (b * p[i].y) == 0) {
						num = 0;
					   	break;
					}	
				}
				
				if(num == N) {
					mark = 1;
					break;	
				}		
			}
			if(mark)
				break;
		}

		printf("%d %d\n", a,b);
	}
	return 0;
}