欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

轻松掌握数学基础:K. 点与三角形的秘密(用叉积法计算面积)

最编程 2024-02-16 20:11:53
...
#pragma GCC optimize(2) #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll>PLL; typedef pair<int,int>PII; typedef pair<double,double>PDD; #define I_int ll inline ll read() { ll x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); } return x*f; } #define read read() #define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define multiCase int T;cin>>T;for(int t=1;t<=T;t++) #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define repp(i,a,b) for(int i=(a);i<(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) #define perr(i,a,b) for(int i=(a);i>(b);i--) ll ksm(ll a,ll b,ll p) { ll res=1; while(b) { if(b&1)res=res*a%p; a=a*a%p; b>>=1; } return res; } #define PI acos(-1) const double eps=1e-10; struct node { double x,y; node operator - (node &s){ return (node){x-s.x,y-s.y}; } }; double operator*(node a,node b){ return a.x*b.y-b.x*a.y; } double cul(node a,node b,node c){ return fabs((b-a)*(c-a)/2); } int main() { node a,b,c,d; cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y; double abc=cul(a,b,c); double abd=cul(a,b,d); double acd=cul(a,c,d); double bcd=cul(b,c,d); if(abd+acd+bcd==abc) puts("in"); else puts("out"); return 0; }