日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

luogu1355 神秘大三角

發(fā)布時(shí)間:2023/12/18 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 luogu1355 神秘大三角 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題解:

計(jì)算幾何入門題

按逆時(shí)針方向訪問三角形的邊

然后作叉積判斷點(diǎn)是否在邊的順時(shí)針方向

叉積和點(diǎn)積都有分配率 但不滿足結(jié)合律

代碼:

#include <bits/stdc++.h> using namespace std; #define rint register int #define IL inline #define rep(i,h,t) for (int i=h;i<=t;i++) #define dep(i,t,h) for (int i=t;i>=h;i--) #define me(x) memset(x,0,sizeof(x)) #define mid ((h+t)>>1) namespace IO{char ss[1<<24],*A=ss,*B=ss;IL char gc(){return A==B&&(B=(A=ss)+fread(ss,1,1<<24,stdin),A==B)?EOF:*A++;}template<class T>void read(T &x){rint f=1,c; while (c=gc(),c<48||c>57) if (c=='-') f=-1; x=(c^48);while (c=gc(),c>47&&c<58) x=(x<<3)+(x<<1)+(c^48); x*=f; } }; using namespace IO; struct Point{int x,y;Point(){};Point(int x1,int y1){x=x1,y=y1;}Point operator +(const Point b)const{return Point(x+b.x,y+b.y);}Point operator -(const Point b)const{return Point(x-b.x,y-b.y);}int operator *(const Point b)const{return b.x*x+b.y*y; }int operator ^(const Point b)const{return x*b.y-y*b.x;}bool operator ==(const Point b)const{if (y==b.y&&x==b.x) return(1); else return(0);} }; struct Line{Point x,y;Line() {};Line(Point x1,Point y1){x=x1,y=y1;} }; int main() {int x1,y1,x2,y2,x3,y3,x,y;Point p1,p2,p3,p;read(x1); read(y1); p1=Point(x1,y1); read(x2); read(y2); p2=Point(x2,y2);read(x3); read(y3); p3=Point(x3,y3);read(x); read(y); p=Point(x,y); if (((p3-p1)^(p2-p1))>0) swap(p3,p1); if (p==p1||p==p2||p==p3){cout<<4<<endl;exit(0);}int tt=1;if (((p3-p1)^(p-p1))>0) tt=2;if (((p3-p1)^(p-p1))==0) tt=3;if (((p1-p2)^(p-p2))>0) tt=2;if (((p1-p2)^(p-p2))==0) tt=3;if (((p2-p3)^(p-p3))>0) tt=2;if (((p2-p3)^(p-p3))==0) tt=3; cout<<tt<<endl;return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/yinwuxiao/p/9986072.html

總結(jié)

以上是生活随笔為你收集整理的luogu1355 神秘大三角的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。