UVA 10167 Birthday Cake

直接暴力枚举即可

 

#include<stdio.h>

int main()

{

    int n, i, j, k;

    int x[1000], y[1000];

    while (~scanf("%d", &n))

    {

        if (n == 0) break;

        int sum1 = 0,sum2=0;

        int flag = 0;

        for (i = 0; i < 2 * n; i++) scanf("%d%d", &x[i], &y[i]);

        for (i = -500; i <= 500; i++)

        {

            sum1 = 0; sum2 = 0;

            for (j = -500; j <= 500; j++)

            {

                sum1 = 0; sum2 = 0;

                for (k = 0; k < 2 * n; k++)

                {

                    if (i*x[k] + j*y[k]>0) sum1++;

                    if (i*x[k] + j*y[k] < 0) sum2++;

                }

                if (sum1==sum2&&sum1==n) { flag = 1; break; }

            }

            if (flag == 1) break;

        }

        printf("%d %d\n", i, j);

    }

    return 0;

}

 

你可能感兴趣的:(birt)