现在的位置: 首页 > 综合 > 正文

zoj 2554 Brownie Points

2013年03月18日 ⁄ 综合 ⁄ 共 628字 ⁄ 字号 评论关闭
//刚开始,读了很久题目,也不是很明白题目的要求是什么!经过再三阅读,才明白!
//题目要求是:在给出的这么多个坐标中,取中间的坐标为原点,然后分别统计落在第一和第三象限,
//第二和第四象限的坐标点个数!
#include "iostream"
using namespace std;

struct Info
{
	int x;
	int y;
};
Info info[200010];

int main()
{
	int n, i, j, ans1, ans2;
	Info centerpoint;
	while (cin >> n && n)
	{
		for (i = 0; i < n; i++)
			cin >> info[i].x >> info[i].y;
		j = (n-1) / 2;
		ans1 = ans2 = 0;
		centerpoint.x = info[j].x, centerpoint.y = info[j].y;
		for (i = 0; i < n; i++)
		{
			if ((info[i].x > centerpoint.x && info[i].y > centerpoint.y) || (info[i].x < centerpoint.x && info[i].y < centerpoint.y))
				ans1++;
			else if ((info[i].x > centerpoint.x && info[i].y < centerpoint.y) || (info[i].x < centerpoint.x && info[i].y > centerpoint.y))
				ans2++;
		}
		cout << ans1 << " " << ans2 << endl;
	}
}

抱歉!评论已关闭.