从此踏上计算几何的不归路……
#include <algorithm> #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <map> #include <set> #include <list> #include <stack> #include <queue> #include <deque> #include <vector> #include <string> #include <bitset> #include <memory> #include <complex> #include <numeric> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <time.h> #include <ctype.h> #include <locale.h> using namespace std; #pragma pack(4) const double eps = 1e-8; const double pi = acos(-1.0); const int inf = 0x7f7f7f7f; #define loop(a,n) \ for(int i=0;n>i;i++) \ cout<<a[i]<<(i!=n-1?' ':'\n') #define loop2(a,n,m) \ for(int i=0;n>i;i++) \ for(int j=0;m>j;j++) \ cout<<a[i][j]<<(j!=m-1?' ':'\n') #define at(a,i) ((a)&(1<<(i))) #define nt(a,i) ((a)^(1<<(i))) #define set1(a,i) ((a)|(1<<(i))) #define set0(a,i) ((a)&(~(1<<(i)))) #define gret(a,b) (((a)-(b))>eps) #define less(a,b) (((b)-(a))>eps) #define greq(a,b) (((a)-(b))>-eps) #define leeq(a,b) (((b)-(a))>-eps) #define equl(a,b) (fabs((a)-(b))<eps) #define lmax(a,b) ((a)>(b)?(a):(b)) #define lmin(a,b) ((a)<(b)?(a):(b)) #define fmax(a,b) (gret(a,b)?(a):(b)) #define fmin(a,b) (less(a,b)?(a):(b)) const int MAXV = 100002; struct point { double c[2]; point(double x=0,double y=0) { c[0]=x; c[1]=y; } double & operator [] (int i) { return c[i]; } point operator + (point argu) { return point(c[0]+argu[0],c[1]+argu[1]); } point operator - (point argu) { return point(c[0]-argu[0],c[1]-argu[1]); } double operator * (point argu) { return c[0]*argu[0]+c[1]*argu[1]; } double operator / (point argu) { return c[0]*argu[1]-c[1]*argu[0]; } }; double area2(point o,point a,point b) { return (a-o)/(b-o); } struct seg { point p[2]; seg(point a,point b) { p[0]=a; p[1]=b; } seg(double x1=0,double y1=0,double x2=0,double y2=0) { p[0]=point(x1,y1); p[1]=point(x2,y2); } point & operator [] (int i) { return p[i]; } }a[MAXV]; bool inter(seg a,seg b) { return less(area2(a[0],a[1],b[0])*area2(a[0],a[1],b[1]),0)&& less(area2(b[0],b[1],a[0])*area2(b[0],b[1],a[1]),0); } int n; int main() { #ifndef ONLINE_JUDGE freopen("Pick-up sticks.txt","r",stdin); #endif while(scanf("%d",&n),n) { for(int i=1;n>=i;i++) { scanf("%lf %lf %lf %lf",&a[i][0][0],&a[i][0][1],&a[i][1][0],&a[i][1][1]); } printf("Top sticks:"); int cnt=0; for(int i=1;n>=i;i++) { bool flag=true; for(int j=i+1;n>=j;j++) { if(inter(a[i],a[j])) { flag=false; break; } } if(flag) { if(cnt++) printf(","); printf(" %d",i); } } printf(".\n"); } return 0; }