[BZOJ4445] [Scoi2015] small convex want to run (half plane turn) __

Source: Internet
Author: User
Topic Description

Transmission Door

The main idea: a convex n-shaped, n vertices are numbered counterclockwise from the 0~n-l. Now a small convex random selection of a position in the polygon, 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 face of the triangle
The product is the smallest of the n triangles, and the small convex is considered to be a correct stance. Now little Cam wants to know what the probability is that he will be right at once. Solving

The selected position coordinates are (x,y) and the equation is made with a fork
(x1−x) (y2−y) − (y1−y) (x2−x) ≤ (xk−x) (yk+1−y) − (xk+1−x) (yk−y) (x_1-x) (y_2-y)-(y_1-y) (x_2-x) \le (x_k-x) (y_{k+1}-y)-(x_{k+1}-x ) (Y_K-Y)
(y1−y2−yk+yk+1) x+ (x2−x1−xk+1+xk) y+ (X1y2−x2y1−xkyk+1+xk+1yk) ≤0 (y_1-y_2-y_k+y_{k+1}) x+ (X_2-x_1-x_{k+1}+x_k) y+ (x_ 1y_2-x_2y_1-x_ky_{k+1}+x_{k+1}y_k) \le 0
This is a linear form of the ax+by+c≤0 Ax+by+c\le 0, which judges the direction of the line according to the ABC notation, and gives the case that AB is 0.
Then all the straight lines hand over a convex shell, and the area of the convex shell/original area is OK.
This problem is a bit accurate, EPS open 1e-15 code

#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <
Cmath> using namespace std;
#define N 200005 const double eps=1e-15;
const double INF=1E18;
    int dcmp (double x) {if (x<=eps&&x>=-eps) return 0;
Return (x>0) 1:-1;
    struct Vector {double x,y;
    Vector (double x=0,double y=0) {x=x,y=y;
}
};
typedef Vector Point; struct line {point P;
    Vector v;
    Double ang;
        Line (Point P=point (0,0), Vector v=vector (0,0)) {p=p,v=v;
    Ang=atan2 (v.y,v.x);
    BOOL operator < (const line &a) Const {return ang<a.ang;
}
};
Vector operator + (vector a,vector b) {return vector (A.X+B.X,A.Y+B.Y);}
Vector operator-(vector a,vector b) {return vector (A.X-B.X,A.Y-B.Y);}

Vector operator * (vector a,double b) {return vector (a.x*b,a.y*b);}
int n,line,cnt,l,r;
Double Area,ans;
Line l[n<<1],q[n<<1]; Point Pt[n],p[n<<1],poly[n<<1]; Double Cross (Vector A,vector b) {  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.