NYOJ 1016 判断两线段是否相交
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<cstring>
#include<queue>
#include<set>
#include<string>
#include<map>
#include <time.h>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = +;
const int sigma=;
const ll mod = ;
const int INF = 0x3f3f3f;
const db eps = 1e-;
struct point {
db x, y;
point(db x=, db y=):x(x), y(y) {}
}s1, e1, s2, e2; typedef point Vector;
Vector operator - (point A, point B) {
return Vector(A.x-B.x, A.y-B.y);
}
db Cross(point A, point B) {
return A.x*B.y-B.x*A.y;
}
void solve() {
scanf("%lf%lf%lf%lf", &s1.x, &s1.y, &e1.x, &e1.y);
scanf("%lf%lf%lf%lf", &s2.x, &s2.y, &e2.x, &e2.y);
Vector CA=s1-s2;
Vector CD=e2-s2;
Vector CB=e1-s2;
db s=Cross(CA, CD)*Cross(CB, CD);
Vector AC=s2-s1;
Vector AB=e1-s1;
Vector AD=e2-s1;
db ss=Cross(AC, AB)*Cross(AD, AB);
// cout<<s<<" "<<ss<<endl;
if (s<= && ss<=) puts("Interseetion");
else puts("Not Interseetion");
}
int main() {
int t = ;
// freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
scanf("%d", &t);
while(t--) {
solve();
}
return ;
}
NYOJ 1016 判断两线段是否相交的更多相关文章
- You can Solve a Geometry Problem too(判断两线段是否相交)
		
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
 - Pick-up sticks--poj2653(判断两线段是否相交)
		
http://poj.org/problem?id=2653 题目大意:有n根各种长度的棍 一同洒在地上 求在最上面的棍子有那几个 分析: 我刚开始想倒着遍历 因为n是100000 想着会 ...
 - You can Solve a Geometry Problem too (hdu1086)几何,判断两线段相交
		
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3276 ...
 - hdu 1086:You can Solve a Geometry Problem too(计算几何,判断两线段相交,水题)
		
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
 - hdu 1147:Pick-up sticks(基本题,判断两线段相交)
		
Pick-up sticks Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
 - poj 1127:Jack Straws(判断两线段相交 + 并查集)
		
Jack Straws Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2911 Accepted: 1322 Descr ...
 - UVALive7461 - Separating Pebbles 判断两个凸包相交
		
//UVALive7461 - Separating Pebbles 判断两个凸包相交 #include <bits/stdc++.h> using namespace std; #def ...
 - 如何判断单链表是否存在环 & 判断两链表是否相交
		
给定一个单链表,只给出头指针h: 1.如何判断是否存在环? 2.如何知道环的长度? 3.如何找出环的连接点在哪里? 4.带环链表的长度是多少? 解法: 1.对于问题1,使用追赶的方法,设定两个指针sl ...
 - poj 1127 -- Jack Straws(计算几何判断两线段相交 + 并查集)
		
Jack Straws In the game of Jack Straws, a number of plastic or wooden "straws" are dumped ...
 
随机推荐
- SVN集成compare4比较软件
			
打开TortoiseSVN的Setting,选择左边的Diff Viewer 设置如下: "D:\Program Files\Beyond Compare 4\BComp.exe" ...
 - 【git】日志提交规范
			
我自己总结的规范: feature: 功能添加bugfix: bug修复change: 调整,比如配置,某些方法替换等optimize: 优化过程doc: 文档变更refactor: 重构,功能不变t ...
 - Linux编译命令-pthread & -lpthread
			
编译makefile的时候到make编译连接阶段总是提示,无法打开某某库或者某某库的格式不对(1 先看看32位,64位是否对应:BITS,cflags lflags....,2 是否将.OS .a等依 ...
 - 【网络编程三】网络通信之多进程(线程)实现TCP通信(一)
			
[多进程] [多线程] /************************************************************************* > File sum ...
 - 【校招面试 之 网络】第3题 HTTP请求行、请求头、请求体详解
			
1.HTTP请求报文解剖 HTTP请求报文由3部分组成(请求行+请求头+请求体): 下面是一个实际的请求报文: ①是请求方法,GET和POST是最常见的HTTP方法,除此以外还包括DELETE.HEA ...
 - spring+quartz报错:Table 'XXXX.QRTZ_TRIGGERS' doesn't exist
			
Spring4.3.4 + quartz2.2.1配置到application.xml中 <properties> <spring.version>4.3.4.RELEASE& ...
 - cgi  fast-cgi   php-fpm区别
			
php-cli 是php在系统执行的程序,直接执行php文件: cgi和fast-cgi的区别1.cgi和fast-cgi都是php解析协议,负责解析服务器分发过来的php动态文件:cgi程序就会去解 ...
 - mysql decimal(10,2)对应java类型
			
下面我给出MYSQL类型与JAVA类型对应表,希望能够帮到您: 类型名称 显示长度 数据库类型 JAVA类型 JDBC类型索引(int) VARCHAR L+N VARCHAR java.lang.S ...
 - C++中stl的map
			
总结: 在map中插入数据有三种方法: 1.用insert插入pair数据: mapstudent.insert(pair<int,string>(1,"studentone&q ...
 - PAT 1049 数列的片段和(20)(代码+思路分析)
			
1049 数列的片段和(20)(20 分) 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段.例如,给定数列{0.1, 0.2, 0.3, 0.4},我们有(0.1) (0.1, 0.2 ...