U E D R , A S I H C RSS

Birthdat Cake/하기웅

^^
Accepted ^^

ax+by=0 , x,y ax+by>0 -a/b
ax+by<0면 -a/b라는 기울기의 직선보다 아래에 있는 점이다.

a, b for 통해 .

~cpp
#include <iostream>
using namespace std;

struct Point {
	int x;
	int y;
};

int cherry, i, j, k, a, b;
Point ch[100];

Point getLine()
{
	Point temp;
	for(i=0; i<500; i++)
	{
		for(j=1; j<=500; j++)
		{
			a=0; b=0;
			for(k=0; k<2*cherry; k++)
			{
				if((i*ch[k].x+j*ch[k].y)>0)
					a++;
				else if((i*ch[k].x+j*ch[k].y)<0)
					b++;
			}

			if(a==cherry && b==cherry)
			{
				temp.x = i;
				temp.y = j;
				return temp;
			}
		}
		for(j=-1; j>=-500; j--)
		{
			a=0; b=0;
			for(k=0; k<2*cherry; k++)
			{
				if((i*ch[k].x+j*ch[k].y)>0)
					a++;
				else if((i*ch[k].x+j*ch[k].y)<0)
					b++;
			}

			if(a==cherry && b==cherry)
			{
				temp.x = i;
				temp.y = j;
				return temp;
			}
		}
	}
}

int main()
{
	while(cin>>cherry)
	{
		if(cherry==0)
			break;
		for(i=0; i<2*cherry; i++)
			cin >> ch[i].x >> ch[i].y;
		cout << getLine().x <<" " <<getLine().y<< endl;	
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:37
Processing time 0.0097 sec