题目:意思就是推断给定的几条线段是否有相交的。

方法:模版吧,有空在来细细学习。

代码:

#include <iostream>
#include <cstdio>
using namespace std;
struct Point
{
double x,y;
};
struct LineSeg
{
Point a,b;
};
double Cross(Point a, Point b, Point c )
{
return (c.x - a.x)*(b.y - a.y) - (b.x - a.x)*(c.y - a.y);
}
int Yu(LineSeg u,LineSeg v)
{
return( (max(u.a.x,u.b.x)>=min(v.a.x,v.b.x))&&
(max(v.a.x,v.b.x)>=min(u.a.x,u.b.x))&&
(max(u.a.y,u.b.y)>=min(v.a.y,v.b.y))&&
(max(v.a.y,v.b.y)>=min(u.a.y,u.b.y))&&
(Cross(v.a,u.b,u.a)*Cross(u.b,v.b,u.a)>=0)&&
(Cross(u.a,v.b,v.a)*Cross(v.b,u.b,v.a)>=0));
} int main()
{
int n;
int flag=0;
LineSeg l[2002];
while(cin>>n)
{
flag=0;
for(int i=0;i<n;i++)
{
scanf("%lf%lf%lf%lf",&l[i].a.x,&l[i].a.y,&l[i].b.x,&l[i].b.y);
if(!flag)
for(int j=0;j<i;j++)
if(Yu(l[j],l[i]))
{
flag=1;
break;
}
}
if(!flag) cout<<"ok!"<<endl;
else cout<<"burned!"<<endl;
}
return 0;
}

zoj 1648 Circuit Board的更多相关文章

  1. ZOJ 1648 Circuit Board(计算几何)

    Circuit Board Time Limit: 2 Seconds Memory Limit: 65536 KB On the circuit board, there are lots of c ...

  2. ZOJ1648 Circuit Board 2017-04-18 20:31 34人阅读 评论(0) 收藏

    Circuit Board Time Limit: 2 Seconds      Memory Limit: 65536 KB On the circuit board, there are lots ...

  3. zoj 1648 判断线段是否相交

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=648 Circuit Board Time Limit: 2 Second ...

  4. Printed Circuit Board (board)

    Printed Circuit Board (board) 题目描述 给出一个N个顶点的简单多边形,对于每个顶点,假如它和原点连成的线段只在这个顶点处和多边形相交,就称为满足要求的顶点.你的任务是输出 ...

  5. NEFU 506&&ZOJ 3353 Chess Board (四种构造的高斯消元)

    题目链接 题意:有四种翻转方式,问是否能使得所有棋子都变为0,求最小步数. 题解:依次构造枚举求出最小值即可. #include <iostream> #include <cstdi ...

  6. ZOJ1648 Circuit Board(线段相交)

    裸的判断线段相交

  7. bzoj2856: [ceoi2012]Printed Circuit Board

    Description 给出一个N个顶点的简单多边形,对于每个顶点,假如它和原点连成的线段只在这个顶点处和多边形相交,就称为满足要求的顶点.你的任务是输出所有满足要求的顶点编号. Input 第一行一 ...

  8. kickstart2019 round_C B. Circuit Board

    思路: 这题应该不止一种解法,其中的一种可以看作是leetcode85https://www.cnblogs.com/wangyiming/p/11059176.html的加强版: 首先对于每一行,分 ...

  9. zoj 1010 Area【线段相交问题】

    链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1010 http://acm.hust.edu.cn/vjudge/ ...

随机推荐

  1. [转]linux下ulimit命令详解

    转自:http://blog.chinaunix.net/uid-23842323-id-2656582.html 1,说明:ulimit用于shell启动进程所占用的资源.2,类别:shell内建命 ...

  2. layer实现在前台删除前确认弹出框,并回调后台删除事件

    最近遇到一些问题,用layer提示消息框,比如删除时,提示消息确定后 return false时,则不管用了,因为layer不支持阻塞,下面就解决一下这个问题:(本文使用Xcode,如要学习,请复下面 ...

  3. MVC系列学习(十五)-验证码

    1.方式一: public class VCode { /// <summary> /// 生成验证码图片 字节数组 /// </summary> /// <return ...

  4. Java_注解之一

    注解可以替换复杂的hbm.xml文件,使得程序的开发大大简化 @Override    :子类重写父类方法 @Test :junit测试 @Before :测试之前执行 @SuppressWarnin ...

  5. Java编程思想读书笔记_第二章

    java对于将一个较大作用域的变量“隐藏”的场景会有保护:编译告警.比如: int x = 5; { int x = 6; } 但是对于类中方法的局部变量和类成员变量确是可以重名的,比如 class ...

  6. CF832B Petya and Exam

    思路: 模拟. 实现: #include <iostream> using namespace std; string a, b; ]; bool solve() { ) return f ...

  7. AIDL跨进程通信报Intent must be explicit

    在Android5.0机子上采用隐式启动来调试AIDL时,会出现Intent must be explicit的错误,原因是5.0的机子不允许使用隐式启动方式,解决的方法是:在启动intent时添加i ...

  8. Json——一般应用

    引用命名空间 using Newtonsoft.Json; 序列化类或者类的集合 string jsonData1 = JsonConvert.SerializeObject(p1);//序列化类 s ...

  9. 如何让字体大小<12px

    transform:scale( ) -webkit-transform:scale( )  

  10. ubuntu14.0开机guest账号禁用方法

    在终端里进入/usr/share/lightdm/lightdm.conf.d/目录 sudo vim 50-unity-greeter.conf 然后在文件里输入: [SeatDefaults] a ...