51NOD 1264 线段相交
来源:互联网 发布:手机店铺销售软件 编辑:程序博客网 时间:2024/05/16 08:33
就是判断两条线段是否相交。
要么判断MBR 要么判断跨立。
计算叉积的乘积。判断跨立。叉积的几何意义,参见matrix67大神的博客。
#include<cstdio>#include<cstring>#include<string>#include<queue>#include<algorithm>#include<map>#include<stack>#include<iostream>//#include<list>//#include<set>//#include<bitset>#include<vector>//#include<valarray>#include<cmath>#define INF 0x7fffffff#define eps 1e-6#define LL long long#define PI 3.141592654#define CLR(a,b) memset(a,b,sizeof(a))#define FOR(i,a,b) for(int i=a;i<b;i++)#define REP(i,a,b) for(int i=a;i>=b;i--)#define sf scanf#define pf printf#define all(v) (v).begin(),(v).end()#define acfun std::ios::sync_with_stdio(false)#define DEBUG freopen("in.txt","r",stdin);\freopen("out.txt","w",stdout);#define SIZE (1000 +2)#define MOD 1000000007using namespace std;struct point{ double x,y; point(double xx=0,double yy=0){x=xx,y=yy;}};inline point getvector(point a,point b){ point tmp(b.x-a.x,b.y-a.y); return tmp;}inline double crossproduct(point a,point b){ return a.x*b.y-a.y*b.x;}bool solve(point a,point b,point c,point d){ point ca,cb,cd,ac,ad,ab; ca=getvector(c,a); cb=getvector(c,b); cd=getvector(c,d); ac=getvector(a,c); ad=getvector(a,d); ab=getvector(a,b); if(crossproduct(cd,ca)*crossproduct(cd,cb)<=0&& crossproduct(ac,ab)*crossproduct(ad,ab)<=0) return 1; else return 0;}int main(){ int t; sf("%d",&t); while(t--) { point l[4]; FOR(i,0,4) sf("%lf%lf",&l[i].x,&l[i].y); if(solve(l[0],l[1],l[2],l[3])) puts("Yes"); else puts("No"); }}
0 0
- 51nod 1264 线段相交
- 51NOD 1264 线段相交
- 51 nod 1264 线段相交
- [51nod]1264 线段相交
- 51nod 1264 线段相交
- 51nod 1264 线段相交
- 51nod 1264 线段相交
- 51nod 1264 线段相交
- 51nod 1264 线段相交
- 51Nod 1264 线段相交
- 51nod 1264 线段相交
- 【51 nod 1264 线段相交 】
- 51Nod-1264 线段相交
- 51Nod 1264 线段相交
- 51Nod-1264-线段相交
- 51Nod 1264 线段相交
- 51Nod-线段相交
- 51nod 1264 线段相交 (模板)
- iis6.0 页面伪静态 URLRewriter
- 状态机按键消抖
- 阿里笔试之最长公共子串
- Xposed源码剖析——app_process作用详解
- iOS开发 -- 通知Notification
- 51NOD 1264 线段相交
- HttpURLConnection----利用接口回调和多线程进行简单的文件下载
- HBase+ZooKeeper+Hadoop2.6.0的ResourceManager HA集群高可用配置
- C++停止服务及其依赖项
- CoCreateInstance
- __Weak的用法
- 禁止横屏(竖屏显示),去掉标题
- DR图像处理技术
- UVA 129 Krypton Factor