萌新求助40分
查看原帖
萌新求助40分
523541
wdy1028楼主2022/2/2 16:56
#include <bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define mem(arr,val) memset((arr),(val),(sizeof(arr)))
#define INT vector<int>
using namespace std;
const int INF = 0x3f3f3f;
const double eps = 1e-8;
struct Point {double x,y;}A,B,C,D;
typedef Point Vector;
inline Point operator-(const Point& A,const Point& B) {return (Point){A.x-B.x,A.y-B.y};}
inline Point operator+(const Point& A,const Point& B) {return (Point){A.x+B.x,A.y+B.y};}
inline int sgn(double x) {return fabs(x)<eps?0:(x<0?-1:1);}
inline int dcmp(double x,double y) {return fabs(x-y)<eps?0:(x<y?-1:1);}
inline double Cross(Vector A,Vector B) {return A.x*B.x-A.y*B.y;}
inline double Area(Point A,Point B,Point C) {return fabs(Cross(B-A,C-A)/2);}
inline int _1_2(Point A,Point B,Point C,Point D)
{
    double a = Area(A,D,C),b = Area(B,D,C),c = Area(A,D,B),d = Area(A,B,C);
    if(a+b+c > d) return 2;
    else if(a+b+c == d) return 1;
    else return 0;
}
inline int _4_(Point A,Point B,Point C,Point D)
{
    if(!dcmp(A.x,D.x) && !dcmp(A.y,D.y)) return 4;
    else if(!dcmp(B.x,D.x) && !dcmp(B.y,D.y)) return 4;
    else if(!dcmp(C.x,D.x) && !dcmp(C.y,D.y)) return 4;
    else return 0;
}
int main(int argc,char *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL),cout.tie(NULL);
	scanf("(%d,%d)\n",&A.x,&A.y);
    scanf("(%d,%d)\n",&B.x,&B.y);
    scanf("(%d,%d)\n",&C.x,&C.y);
    scanf("(%d,%d)\n",&D.x,&D.y);
    int __1__2 = _1_2(A,B,C,D);
    if(__1__2 == 1 || __1__2 == 2) {cout<<__1__2<<endl;return 0;}
    int _4 = _4_(A,B,C,D);
    if(_4 == 4) {cout<<_4<<endl;return 0;}
    cout<<3<<endl;
    return 0;
}
2022/2/2 16:56
加载中...