¶
뭔가 기 방법 까 각 많다가 그냥 노가다로 렸다^^
그런데 뭐 단방 Accepted가 되 당다^^
ax+by=0 라는 때, 기 x,y를 대 ax+by>0면 -a/b라는 기기 보다 는 라는 것고
ax+by<0면 -a/b라는 기울기의 직선보다 아래에 있는 점이다.
것 a, b를 for문 변 가면 는 과 래 는 개가 똑같 때 기기를 는 방.
그런데 뭐 단방 Accepted가 되 당다^^
ax+by<0면 -a/b라는 기울기의 직선보다 아래에 있는 점이다.
¶
~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; }