POJ2460 HDU1152 Brownie Points I水题

Posted 海岛Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了POJ2460 HDU1152 Brownie Points I水题相关的知识,希望对你有一定的参考价值。

Brownie Points I
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 1438 Accepted: 903

Description

Stan and Ollie play the game of Odd Brownie Points. Some brownie points are located in the plane, at integer coordinates. Stan plays first and places a vertical line in the plane. The line must go through a brownie point and may cross many (with the same x-coordinate). Then Ollie places a horizontal line that must cross a brownie point already crossed by the vertical line.
Those lines divide the plane into four quadrants. The quadrant containing points with arbitrarily large positive coordinates is the top-right quadrant.

The players score according to the number of brownie points in the quadrants. If a brownie point is crossed by a line, it doesn’t count. Stan gets a point for each (uncrossed) brownie point in the top-right and bottom-left quadrants. Ollie gets a point for each (uncrossed) brownie point in the top-left and bottom-right quadrants.

Your task is to compute the scores of Stan and Ollie given the point through which they draw their lines.

Input

Input contains a number of test cases. The data of each test case appear on a sequence of input lines. The first line of each test case contains a positive odd integer 1 < n < 200000 which is the number of brownie points. Each of the following n lines contains two integers, the horizontal (x) and vertical (y) coordinates of a brownie point. No two brownie points occupy the same place. The input ends with a line containing 0 (instead of the n of a test).

Output

For each test case of input, print a line with two numbers separated by a single space. The first number is Stan’s score, the second is the score of Ollie when their lines cross the point whose coordinates are given at the center of the input sequence of points for this case.

Sample Input

11
3 2
3 3
3 4
3 6
2 -2
1 -3
0 0
-3 -3
-3 -2
-3 -4
3 -7
0

Sample Output

6 3

Source

Waterloo local 2005.06.11

问题链接POJ2460 HDU1152 Brownie Points I
问题简述:(略)
问题分析:水题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* POJ2460 HDU1152 Brownie Points I */

#include <iostream>
#include <cstdio>

using namespace std;

const int N = 200000;
int x[N], y[N];

int main()
{
    int n;
    while (~scanf("%d", &n) && n) {
        for (int i = 0; i < n; i++)
            scanf("%d%d", &x[i], &y[i]);

        int x0 = x[n / 2], y0 = y[n / 2], cnt1 = 0, cnt2 = 0;
        for (int i = 0; i < n; i++)
            if (x[i] > x0 && y[i] > y0) cnt1++;
            else if (x[i] < x0 && y[i] < y0) cnt1++;
            else if (x[i] < x0 && y[i] > y0) cnt2++;
            else if (x[i] > x0 && y[i] < y0) cnt2++;

        printf("%d %d\\n", cnt1, cnt2);
    }

    return 0;
}

以上是关于POJ2460 HDU1152 Brownie Points I水题的主要内容,如果未能解决你的问题,请参考以下文章

简单数论(poj 1152)

hdu&&poj搜索题题号

BZOJ 2460 元素

原根二连 HDU 4992 && poj 1284 Primitive Roots

hdu 4520

hdu1845(a^b的因子和%p)