1 #include
2 #include
3 #include
4 #include
5 #include
6 using namespace std;
7 int n,cnt;
8 const int maxn=55;
9 struct point
10 {
11 double x,y;
12 }p[maxn],a[maxn*maxn];
13 double operator *(const point &a,const point &b)
14 {
15 return a.x*b.y-a.y*b.x;
16 }
17 point operator -(const point &a,const point &b)
18 {
19 return (point){a.x-b.x,a.y-b.y};
20 }
21 struct line
22 {
23 point a,b;double slop;
24 friend bool operator <(const line &a,const line &b)
25 {
26 if(a.slop!=b.slop)return a.slop<b.slop;
27 return (b.b-a.a)*(a.b-a.a)<0;
28 }
29 void print()
30 {
31 printf("%lf %lf %lf %lf\n",a.x,a.y,b.x,b.y);
32 }
33 }l[maxn*maxn],q[maxn*maxn];
34 void pre()
35 {
36 for(int i=1;i<=cnt;i++)l[i].slop=atan2(l[i].b.y-l[i].a.y,l[i].b.x-l[i].a.x);
37 sort(l+1,l+cnt+1);int tot=0;
38 for(int i=1;i<=cnt;i++)
39 {
40 if(l[i].slop!=l[i-1].slop)tot++;
41 l[tot]=l[i];
42 }
43 cnt=tot;
44 }
45 point inter(line a,line b)
46 {
47 double k1,k2;
48 k1=(a.a-b.a)*(a.a-b.b),k2=(a.b-b.b)*(a.b-b.a);
49 k1=k1/(k1+k2);
50 point ans;
51 ans.x=a.a.x+k1*(a.b.x-a.a.x),ans.y=a.a.y+k1*(a.b.y-a.a.y);
52 return ans;
53 }
54 bool judge(point a,line b)
55 {
56 return (b.a-a)*(b.b-a)<0;
57 }
58 void work()
59 {
60 int L=1,R=0;
61 q[++R]=l[1],q[++R]=l[2];
62 for(int i=3;i<=cnt;i++)
63 {
64 while(L1
]),l[i]))R--