51NOD1264线段相交
来源:互联网 发布:淘宝联盟怎么合并付款 编辑:程序博客网 时间:2024/05/20 09:09
题目链接:点击打开链接
解题思路:
用直线和点的关系来判断.把A和B这条线段看成一条直线,分别看C和D关于这条直线的位置关系,如果一正一负,那么必然相交.
完整代码:
#include <algorithm>#include <iostream>#include <cstring>#include <climits>#include <cstdio>#include <string>#include <cmath>#include <set>#include <queue>#include <map>#include <vector>#include <cstdlib>#include <stack>#include <time.h>using namespace std;typedef long long LL;const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const double EPS = 1e-9;const double PI = acos(-1.0); //M_PI;const int maxn = 100001;struct point{ double x , y; point(double a , double b) : x(a) , y(b) {}; point() {}; void input() { scanf("%lf%lf",&x,&y); }};bool line_make_point(point a , point b , point c , point d){ double C = (c.y - a.y) * (a.x - b.x) - (a.y - b.y) * (c.x - a.x); double D = (d.y - a.y) * (a.x - b.x) - (a.y - b.y) * (d.x - a.x); if(C * D > 0) return false; return true;}bool check(point a , point b , point c , point d){ if(!line_make_point(a , b , c , d)) return false; if(!line_make_point(c , d , a , b)) return false; return true;}int main(){#ifdef DoubleQ freopen("in.txt","r",stdin);#endif int T; scanf("%d",&T); while(T--) { struct point a , b , c , d; a.input(); b.input(); c.input(); d.input(); if(check(a , b , c , d)) printf("Yes\n"); else printf("No\n"); } return 0;}/*************************************************** Copyright By DoubleQ* Written in 2015* Blog Address : zhanghe.ac.cn* http://blog.csdn.net/u013447865* Email Address: acmer_doubleq@qq.com**************************************************/
0 0
- 51NOD1264线段相交
- 51nod1264 线段相交
- 51Nod1264 线段相交
- 51nod1264 线段相交
- 51nod1264 线段相交
- 51NOD1264 线段相交(计算几何)
- nod1264 线段相交(计算几何)
- 51nod1264
- 51Nod-线段相交
- 51nod_1264线段相交
- 51nod 1264 线段相交
- 51NOD 1264 线段相交
- 51 nod 1264 线段相交
- [51nod]1264 线段相交
- 51nod 1264 线段相交
- 51nod 1264 线段相交
- 51nod 1264 线段相交
- 51nod 1264 线段相交
- 将整形数据类型转成id类型
- 使用事件循环
- Spring注解讲解
- Git学习 --> 个人常用命令add,commit以及push
- iOS经典讲解之Swift函数详解(一)
- 51NOD1264线段相交
- Parallels Desktop 11 for Mac新增功能
- 168、Excel Sheet Column Title
- PHP的单例模式
- NMEA-0183 协议 ——GPS芯片输出标准格式
- poj1845 Sumdiv 数论
- windows重启mysql命令
- MSBuild入门
- 雪*C语言结构体总结七