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 ...
随机推荐
- leetcode 栈和队列类型题
1,Valid Parentheses bool isVaild1(string& s) { // 直接列举,不易扩展 stack<char> stk; ; i < s.le ...
- poj1845(逆元+快速幂)
题目链接:https://vjudge.net/problem/POJ-1845 题意:求A的B次方的所有因子(包括1)的和对9901的模. 思路:首先对A利用唯一分解定理得A=p1x1*p2x2*. ...
- 数论----gcd和lcm
gcd即最大公约数,lcm即最小公倍数. 首先给出a×b=gcd×lcm 证明:令gcd(a,b)=k,a=xk,b=yk,则a×b=x*y*k*k,而lcm=x*y*k,所以a*b=gcd*lcm. ...
- anaconda的安装tensorflow
在anaconda prompt中我们输入 anaconda search -t conda tensorflow 查看能在哪里安装tensorflow anaconda show dhirschfe ...
- Visual C++ 6.0 创建C语言程序
1 文件-->新建-->”文件“选项卡-->C++ Source File. 2 输入文件名.选择文件位置,点击确定,弹出编辑器窗口. 3 在编辑器窗口中,输入C程序代码,然后保存. ...
- redis 简介,安装与部署
NOSQL简介 NoSQL,泛指非关系型的数据库,NoSQL数据库的四大分类: 键值(Key-Value)存储数据库:这一类数据库主要会使用到一个哈希表,这个表中有一个特定的键和一个指针指向特定的数据 ...
- akuna capital oa
记得截图没过的test case啊!否则连复习改bug的证据都没了啊!!! 其实也不一定非得要拿面试来测试,做做lc的contest,看看自己哪里不会,也是一样的效果. 注意是单选题还是多选题 has ...
- Linux系统下重启Tomcat
在Linux系统下,重启Tomcat使用命令操作的! 首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ./shutdown.sh 查看 ...
- JFinal Model判断数据库某条记录的属性字段是否包含空值
如果做报表,一条记录中有空值,使用FreeMarker渲染word会报错,并把错误日志输出到Word中.所以需要之前判断下当前记录中属性值是否有空值. package com.huijiasoft.u ...
- Solidity语言基础 和 Etherum ERC20合约基础
1. 类型只能从第一次赋值中推断出来,因此以下代码中的循环是无限的, 小. for (var i = 0; i < 2000; i++) { ... } --- Solidity Types ...