poj 3304
来源:互联网 发布:抓取京东商品信息 php 编辑:程序博客网 时间:2024/05/29 13:58
知识点:线段与直线相交,注意枚举时重合点的处理
#include<iostream>#include<math.h>using namespace std;#define esp 1e-8struct Point { double x,y; Point(){} Point(double x0,double y0):x(x0),y(y0){}};/*bool isEqual(double &a,double &b){ return fabs(a-b)<esp;}*/double mult(Point st,Point ed,Point md){//叉积判断点在直线的左右位置,<0,左侧,>0右侧! return ((st.x-md.x)*(ed.y-md.y)-(ed.x-md.x)*(st.y-md.y));}Point p[402];int main(){ int T,n; scanf("%d",&T); while(T--){ scanf("%d",&n); for(int i=1;i<=2*n;i+=2) scanf("%lf%lf%lf%lf",&p[i].x,&p[i].y,&p[i+1].x,&p[i+1].y); bool f=false,f2; for(int i=1;i<=2*n;i++) { for(int j=i+1;j<=2*n;j++) { if(p[i].x!=p[j].x||p[i].y!=p[j].y) { f=true; for(int g=1;g<=2*n;g+=2) { if(mult(p[g],p[i],p[j])*mult(p[g+1],p[i],p[j])>esp)//判断两线段是否有交点,>0无交点!! { f=false; break; } } if(f) break; } } if(f) break; } if(f) printf("Yes!\n"); else printf("No!\n"); }}
- POJ 3304
- poj 3304
- poj 3304
- poj 3304
- poj 3304
- POJ-3304
- poj 3304
- poj 3304
- poj 3304
- POJ 3304
- poj 3304
- POJ 3304 Segments
- POJ 3304 计算几何
- poj 3304 Segments
- poj 3304 Segments
- poj 3304 Segments
- POJ 3304 Segments
- poj 3304解题报告
- 计算机几何题目
- mysql 游标使用
- 再谈maven自动部署到tomcat的问题
- Hibernate映射解析——七种映射关系
- Windows 开启administrator至欢迎界面
- poj 3304
- 转 Filter及FilterChain的使用详解
- 中国剩余定理
- Delphi 2007 的重构功能
- Ubuntu中root用户和user用户的相互切换
- ffmpeg的一些初学笔记
- poj 1269 知识点:直线相交判断,求相交交点
- 表单的焦点顺序和对应enter键提交
- 几个常用的JavaScript字符串处理函数– split()、join()、substring()和 .