题目描述:
题解:
这道题告诉我们POJ的数据是极强的……
计算几何。
有好几个特殊情况,都在这组数据里面。
106259 2664 8292 9080 1244 2972 9097 96800 1 1 01 0 2 10 1 2 11 0 1 20 0 10 100 0 9 80 0 10 100 0 8 90.9 3.1 4 00 3 2 20 0 0 20 0 -3 21 1 1 40 0 2 31 2 1 40 0 2 30 0 1 10 0 1 2
感谢,
代码:
#include#include #include #include using namespace std;const double eps = 1e-8;int dcmp(double x){ if(fabs(x)<=eps)return 0; return x>0?1:-1;}struct Point{ double x,y; Point(){} Point(double x,double y):x(x),y(y){} Point operator + (const Point&a)const{ return Point(x+a.x,y+a.y);} Point operator - (const Point&a)const{ return Point(x-a.x,y-a.y);} Point operator * (const double&a)const{ return Point(x*a,y*a);} double operator ^ (const Point&a)const{ return x*a.y-y*a.x;}}a,b,c,d;typedef Point Vector;struct Line{ Point p; Vector v; Line(){} Line(Point p,Vector v):p(p),v(v){}}s,t;int n;bool diff(Line l,Point a,Point b){ return dcmp(l.v^(a-l.p))*(l.v^(b-l.p))<=0;}Point L_L(Line a,Line b){ double t = ((b.p-a.p)^b.v)/(a.v^b.v); return a.p+a.v*t;}Point L_Y(Line a,double y){ return a.p+a.v*((y-a.p.y)/a.v.y);}void work(){ scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y); if(a.y