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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ZOJ 1648 线段相交

發布時間:2025/4/14 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ZOJ 1648 线段相交 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題意:

是否存在規范相交

?

View Code 1 #include <iostream> 2 #include <cstdlib> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 #include <cmath> 7 8 #define N 2020 9 #define EPS 1e-4 10 //規范相交 11 using namespace std; 12 13 struct PO 14 { 15 double x,y; 16 }; 17 18 struct LI 19 { 20 PO a,b; 21 }li[N]; 22 23 int n; 24 25 inline int doublecmp(double x) 26 { 27 if(x>EPS) return 1; 28 else if(x<-EPS) return -1; 29 return 0; 30 } 31 32 inline double cross(PO &a,PO &b,PO &c) 33 { 34 return (c.x-a.x)*(b.y-a.y)-(c.y-a.y)*(b.x-a.x); 35 } 36 37 inline double dot(PO &a,PO &b,PO &c) 38 { 39 return (b.x-a.x)*(c.x-a.x)+(b.y-a.y)*(c.y-a.y); 40 } 41 42 inline bool segcross(LI &a,LI &b) 43 { 44 int p1,p2,d1,d2; 45 //b跨立a 46 p1=doublecmp(cross(a.a,a.b,b.a)); 47 p2=doublecmp(cross(a.a,a.b,b.b)); 48 //a跨立b 49 d1=doublecmp(cross(b.a,b.b,a.a)); 50 d2=doublecmp(cross(b.a,b.b,a.b)); 51 if(p1*p2<0&&d1*d2<0) return true; 52 else return false; 53 } 54 55 inline void read() 56 { 57 for(int i=1;i<=n;i++) 58 scanf("%lf%lf%lf%lf",&li[i].a.x,&li[i].a.y,&li[i].b.x,&li[i].b.y); 59 } 60 61 inline void go() 62 { 63 for(int i=1;i<=n;i++) 64 for(int j=i+1;j<=n;j++) 65 if(segcross(li[i],li[j])) {puts("burned!");return;} 66 puts("ok!"); 67 } 68 69 int main() 70 { 71 while(scanf("%d",&n)!=EOF) read(),go(); 72 return 0; 73 }

?

?

轉載于:https://www.cnblogs.com/proverbs/archive/2013/02/23/2923778.html

總結

以上是生活随笔為你收集整理的ZOJ 1648 线段相交的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。