Source Code
Problem: 1279 | User: Faker_fan | |
Memory: 296K | Time: 0MS | |
Language: C++ | Result: Accepted |
- Source Code
#include
#include
#include #include #include #include typedef long long ll; using namespace std; const int maxn=1e4+10; const int mod=998244353; using namespace std; const double eps = 1e-8; int sgn(double x) { if(fabs(x) < eps)return 0; if(x < 0) return -1; return 1; } struct Point { double x,y; Point(){} Point(double _x,double _y) { x = _x;y = _y; } Point operator -(const Point &b)const { return Point(x - b.x,y - b.y); } double operator ^(const Point &b)const { return x*b.y - y*b.x; } double operator *(const Point &b)const { return x*b.x + y*b.y; } double operator ==(const Point &b)const { return x==b.x&&y==b.y; } }; struct Line { Point s,e; Line(){} Line(Point _s,Point _e) { s = _s;e = _e; } }; double xmult(Point p0,Point p1,Point p2) //p0p1 X p0p2 { return (p1-p0)^(p2-p0); } double xmult(Point p0,Point p1,Point p2,Point p3) //p0p1 X p2p3 { return (p1-p0)^(p3-p2); } bool Seg_inter_line(Line l1,Line l2) //判断直线l1和线段l2是否相交 { return sgn(xmult(l2.s,l1.s,l1.e))*sgn(xmult(l2.e,l1.s,l1.e)) <= 0; } Point getIntersectPoint