• NYOJ 1016 判断两线段是否相交


    #include<cstdio>
    #include<cmath>
    #include<iostream>
    #include<algorithm>
    #include<vector>
    #include<stack>
    #include<cstring>
    #include<queue>
    #include<set>
    #include<string>
    #include<map>
    #include <time.h>
    #define PI acos(-1)
    using namespace std;
    typedef long long ll;
    typedef double db;
    const int maxn = 400005+1000;
    const int sigma=26;
    const ll mod = 1000000007;
    const int INF = 0x3f3f3f;
    const db eps = 1e-9;
    struct point {
        db x, y;
        point(db x=0, db y=0):x(x), y(y) {}
    }s1, e1, s2, e2;
    
    typedef point Vector;
    Vector operator - (point A, point B) {
        return Vector(A.x-B.x, A.y-B.y);
    }
    db Cross(point A, point B) {
       return A.x*B.y-B.x*A.y;
    }
    void solve() {
        scanf("%lf%lf%lf%lf", &s1.x, &s1.y, &e1.x, &e1.y);
        scanf("%lf%lf%lf%lf", &s2.x, &s2.y, &e2.x, &e2.y);
        Vector CA=s1-s2;
        Vector CD=e2-s2;
        Vector CB=e1-s2;
        db s=Cross(CA, CD)*Cross(CB, CD);
        Vector AC=s2-s1;
        Vector AB=e1-s1;
        Vector AD=e2-s1;  
        db ss=Cross(AC, AB)*Cross(AD, AB);
       // cout<<s<<" "<<ss<<endl;
        if (s<=0 && ss<=0)  puts("Interseetion");
        else  puts("Not Interseetion");
    }
    int main() {
        int t = 1;
       // freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
        scanf("%d", &t);
        while(t--) {
            solve();
        }
        return 0;
    }
  • 相关阅读:
    DQL、DML、DDL、DCL的概念与区别
    TeamViewer
    构建属于自己的ORM框架之二--IQueryable的奥秘
    某考试 T2 sum
    某考试 T1 line
    bzoj 2153: 设计铁路
    [SCOI2010]序列操作
    [SCOI2010]字符串
    [SCOI2010]传送带
    bzoj 2694: Lcm
  • 原文地址:https://www.cnblogs.com/gggyt/p/7646605.html
Copyright © 2020-2023  润新知