2019牛客多校(第一场)F-Random Point in Triangle

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
struct Point{
    ll x, y;
    Point( ll x=0, ll y=0 ): x(x), y(y){}
};
typedef Point Vector;
Point p[5];
Vector operator -(const Vector a, const Vector b ){
    return Vector( a.x-b.x, a.y-b.y );
}

ll Cross( Vector a, Vector b ){
    return a.x*b.y - a.y*b.x;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x1, y1, x2, y2, x3, y3;
    while( cin >> x1 >> y1 ){
        cin >> x2 >> y2 >> x3 >> y3;
        p[1] = Point(x1, y1);
        p[2] = Point(x2, y2);
        p[3] = Point(x3, y3);
        ll ans = Cross( p[2]-p[1], p[3]-p[1] )*11;
        if( ans<0 ) ans = -ans;
        cout << ans <<endl;
    }

    return 0;
}

 

posted @ 2019-07-19 10:44  CoffeeCati  阅读(1306)  评论(5编辑  收藏  举报