the
Xiao Convex evening like to go to the playground to run, today he finished two laps, he played such a game.
The playground is a convex n-shaped, n vertices are numbered counterclockwise from the 0~n-l. Now a small convex random stand in the playground of a position, marked as P point. The P-point and N-vertices are connected to each other to form n triangles. If the P-point, number No. 0, and point 1th form the triangle's area is the smallest of n triangles, the small convex is considered to be a correct position.
Now little Cam wants to know what the probability is that he will be right at once. Solving
Application of the first half plane intersection.
Tkj taught me.
We consider if we set this point to (X,y) (x, y) (x,y)
So we can list n inequalities with the conditions of n triangles
Which is similar to the inequality of ax+by<=c a x + b y <= c ax+by
This is a classified discussion of B, which can be converted into a number of half planes
And then ask for half a plane to make it.
Finally, the area of the half plane intersection is more than the upper area.
Finally, a mandatory rounding of tkj.
CODE:
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <
Cmath> using namespace std;
typedef double LB;
const int n= (1E5+5) *3;
Const LB eps=1e-15; struct pnt{lb x,y;}
A[n];
struct QQ {PNT x,y;
LB angle;
}s[n];int tot=0;
int n;
void Add (LB x1,lb y1,lb x2,lb y2) {tot++;
S[TOT].X={X1,Y1};
S[TOT].Y={X2,Y2};
S[tot].angle=atan2 (Y2-Y1,X2-X1);
} void Ins (LB a,lb b,lb c)//ax+by<=c {//printf ("Ozy:%lf%lf%lf\n", a,b,c);
if (ABS (b) <eps) {if (a>eps) Add (c/a,0,c/a,1);
else Add (c/a,1,c/a,0);
return;
} PNT P1={0,c/b},p2={1, (c-a)/b};
if (b>eps) Add (P2.X,P2.Y,P1.X,P1.Y);
else Add (P1.X,P1.Y,P2.X,P2.Y);
} lb Mul (pnt x,pnt y,pnt z) {lb x1=x.x-z.x,y1=x.y-z.y;
LB x2=y.x-z.x,y2=y.y-z.y;
return x1*y2-x2*y1;
BOOL CMP (QQ x,qq y) {if (ABS (X.angle-y.angle) <eps) return Mul (x.x,x.y,y.x) <-eps; Return X.angle<y.angLe
int q[n];
PNT JD (QQ x,qq y)//Find the intersection of two straight lines {LB s1=mul (x.y,y.x,x.x);
LB S2=mul (y.y,x.y,x.x);
PNT xx;
xx.x= (Y.X.X*S2+Y.Y.X*S1)/(S1+S2);
xx.y= (Y.X.Y*S2+Y.Y.Y*S1)/(S1+S2);
return xx;
BOOL Check (QQ X,QQ a,qq b) {PNT xx=jd (a,b);
Return Mul (x.y,xx,x.x) <-eps;
} PNT Ans[n];
int nn;
void Solve () {sort (s+1,s+1+tot,cmp); for (int u=1;u<=tot;u++) printf ("%.0lf%.0lf%.0lf%.0lf%.0lf\n", S[u].x.x,s[u].x.y,s[u].y.x,s[u].y.y,s[u].angle
);
Nn=1;
for (int u=2;u<=tot;u++) if (s[u].angle-s[nn].angle>eps) s[++nn]=s[u];
Tot=nn;
int st=1,ed=2;
q[1]=1;q[2]=2;
for (int u=3;u<=tot;u++) {while (St<ed&&check (S[u],s[q[ed]],s[q[ed-1])) ed--;
while (St<ed&&check (s[u],s[q[st]],s[q[st+1])) st++;
Q[++ed]=u;
while (St<ed&&check (S[q[st]],s[q[ed]],s[q[ed-1])) ed--;
while (St<ed&&check (s[q[ed]],s[q[st]],s[q[st+1])) st++; Q[++ED]=Q[ST];
nn=0;
for (int u=st;u<ed;u++) ANS[++NN]=JD (s[q[u]],s[q[u+1]);
int main () {scanf ("%d", &n);
LB sum=0;
for (int u=1;u<=n;u++) scanf ("%lf%lf", &a[u].x,&a[u].y);
for (int u=3;u<=n;u++) Sum=sum+mul (a[u],a[u-1],a[1]);
for (int u=2;u<=n;u++) Add (A[U-1].X,A[U-1].Y,A[U].X,A[U].Y);
Add (A[N].X,A[N].Y,A[1].X,A[1].Y);
for (int u=2;u<=n;u++)//This line segment and the first formed {QQ x=s[1],y=s[u]; Ins (x.x.y-x.y.y-y.x.y+y.y.y, x.y.x-x.x.x+y.x.x-y.y.x, x.x.y* (x.y.x-x.x.x)-x.x.x* (x.y.y-x.x.y)-y.x.y* (y.y.x
-y.x.x) +y.x.x* (y.y.y-y.x.y));
} solve ();
if (nn<=2) {printf ("0.0000\n"); return 0;}
/*for (int u=1;u<=nn;u++) printf ("Tyb:%lf%lf\n", ans[u].x,ans[u].y); */LB lalal=0;
for (int u=1;u<=n;u++) printf ("%lf%lf\n", ans[u].x,ans[u].y);
for (int u=3;u<=nn;u++) Lalal=lalal+mul (ans[u],ans[u-1],ans[1]);
printf ("%.4lf%lf\n", lalal,sum);
Char ss[10]; printf ("%lf\n", ans);
sprintf (SS, "%.6lf", lalal/sum);
if (ss[6]>= ' 5 ') {ss[5]++;
if (ss[5]> ' 9 ') {ss[5]= ' 0 ';
ss[4]++;
} if (ss[4]> ' 9 ') {ss[4]= ' 0 ';
ss[3]++;
} if (ss[3]> ' 9 ') {ss[3]= ' 0 ';
ss[2]++;
} if (ss[2]> ' 9 ') {ss[2]= ' 0 ';
ss[0]++;
} for (int i=0;i<6;i++) printf ("%c", Ss[i]);
return 0; }