Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 15145   Accepted: 6640 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
题目大意:求两条直线的交点坐标. 解题关键:叉积的运用. 证明: 直线的一般方程为$F(x) = ax + by + c = 0$.既然我们已经知道直线的两个点,假设为$(x_0,y_0), (x_1, y_1)$,那么可以得到$a = {y_0} - {y_1}$,$b = x_1 – x_0$,$c = x_0y_1 – x_1y_0$. 因此我们可以将两条直线分别表示为 ${F_0}(x) = {\rm{ }}{a_0}x{\rm{ }} + {\rm{ }}{b_0}y{\rm{ }}…
题目:POJ1269 题意:给你两条直线的坐标,判断两条直线是否共线.平行.相交,若相交,求出交点. 思路:直线相交判断.如果相交求交点. 首先先判断是否共线,之后判断是否平行,如果都不是就直接求交点了. #include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> #include <math.h> #include <queue> #…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8637   Accepted: 3915 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect in a line because they are on top of one another…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 15478   Accepted: 6751 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
题目大意:有一个不反光并且不透光的管道,现在有一束光线从最左端进入,问能达到的最右端是多少,输出x坐标.   分析:刚开始做是直接枚举两个点然后和管道进行相交查询,不过这样做需要考虑的太多,细节不容易掌控.后来发现其实只需要对接口进行一下相交查询就简单多了,因为只需要考虑能不能通过每个截口就可以了,而且这样做的好处还有没有平行线和重叠线的情况,因为所有的截口都是垂直于x轴的,换一种想法海阔太空啊.   代码如下: =========================================…
id=1269" rel="nofollow">Intersecting Lines 大意:给你两条直线的坐标,推断两条直线是否共线.平行.相交.若相交.求出交点. 思路:线段相交推断.求交点的水题.没什么好说的. struct Point{ double x, y; } ; struct Line{ Point a, b; } A, B; double xmult(Point p1, Point p2, Point p) { return (p1.x-p.x)*(p2…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8342   Accepted: 3789 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
题目:http://poj.org/problem?id=1269 相关知识: 叉积求面积:https://www.cnblogs.com/xiexinxinlove/p/3708147.html什么是叉积:https://blog.csdn.net/sunbobosun56801/article/details/78980467        其二维:https://blog.csdn.net/qq_38182397/article/details/80508303计算交点:    方法1:面…
题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0)=0 (p3-p0)X(p2-p0)=0 展开后即是 (y1-y2)x0+(x2-x1)y0+x1y2-x2y1=0 (y3-y4)x0+(x4-x3)y0+x3y4-x4y3=0 将x0,y0作为变量求解二元一次方程组. 假设有二元一次方程组 a1x+b1y+c1=0; a2x+b2y+c2=0…
Pipe Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8280   Accepted: 2483 Description The GX Light Pipeline Company started to prepare bent pipes for the new transgalactic light pipeline. During the design phase of the new pipe shape th…
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7847    Accepted Submission(s): 3834 Problem Description Many geometry(几何)problems were designed in the ACM/…
题目链接:https://vjudge.net/contest/276358#problem/D 题目大意:每一次给你两条直线,然后问你这两条直线的关系(平行,共线,相交(输出交点)). 具体思路:先判断共线,再去判断平行,其次是相交,这些都能通过叉积来判断. 首先输入的是四个点,P1,P2,P3,P4. 共线的话,我们线确定一条直线,P1,P2.然后我们看p1,p2,p3这三个点形成的两条线是不是为0,然后再去看p1,p2,p4形成的两条直线是不是也是0,如果都满足的话,就是共线. 平行的话,…
http://poj.org/problem?id=1269 题目大意:给四个点,求前两个点所构成的直线和后两个点所构成的直线的位置关系(平行,重合,相交),如果是相交,输出交点坐标. —————————————————————— http://blog.csdn.net/zxy_snow/article/details/6341282 这个人的博客有详细的证明过程,这里直接拿来用即可. 应当优先判断向量平行,这样再判断是否重合能更方便些. #include<cstdio> #include&…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12421   Accepted: 5548 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
题意:    判断直线间位置关系: 相交,平行,重合 include <iostream> #include <cstdio> using namespace std; struct Point { int x , y; Point(, ) :x(a), y(b) {} }; struct Line { Point s, e; int a, b, c;//a>=0 Line() {} Line(Point s1,Point e1) : s(s1), e(e1) {} void…
Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect in a line because they are on top of…
水题,以前总结的模板还是很好用的. #include <cstdio> #include <cmath> using namespace std; ; int dcmp(double x) { ; ? - : ; } struct Point { double x, y; Point(, ):x(x), y(y) {} }; typedef Point Vector; Point read_point() { double x, y; scanf("%lf%lf"…
模板题 注意原题中说的线段其实要当成没有端点的直线.被坑了= = #include <cmath> #include <cstdio> #include <iostream> #include <cstring> using namespace std; #define eps 1e-8 #define PI acos(-1.0)//3.14159265358979323846 //判断一个数是否为0,是则返回true,否则返回false #define z…
题目传送门 题意:判断两条直线的位置关系,共线或平行或相交 分析:先判断平行还是共线,最后就是相交.平行用叉积判断向量,共线的话也用叉积判断点,相交求交点 /************************************************ * Author :Running_Time * Created Time :2015/10/24 星期六 09:08:55 * File Name :POJ_1269.cpp *********************************…
题目链接 题意 : 给你两条线段的起点和终点,一共四个点,让你求交点坐标,如果这四个点是共线的,输出“LINE”,如果是平行的就输出“NONE”. 思路 : 照着ZN留下的模板果然好用,直接套上模板了事儿,不过在判断是否共线的时候,其实还有另一种方法,直接将平行和共线一起判断了,我是判断三个点三个点的判断是否是共线. #include <stdio.h> #include <string.h> #include <iostream> using namespace st…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13605   Accepted: 6049 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
题目链接:https://vjudge.net/problem/POJ-1269 题意:给出4个顶点,表示两条直线,求这两条直线的相交情况,重合输出LINE,平行输出NONE,相交于一点输出该点的距离. 思路: 用叉积判断直线的重合和平行,并且可以用叉积求相交直线的交点. 用叉积求直线交点的模板: double t=((a-c)^(c-d))/((a-b)^(c-d)); ans=Point(a.x+(b.x-a.x)*t,a.y+(b.y-a.y)*t) 证明见https://www.cnbl…
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9596    Accepted Submission(s): 4725 Problem Description Many geometry(几何)problems were designed in the ACM/I…
题意: 二维平面,给两条线段,判断形成的直线是否重合,或是相交于一点,或是不相交. 解法: 简单几何. 重合: 叉积为0,且一条线段的一个端点到另一条直线的距离为0 不相交: 不满足重合的情况下叉积为0 相交于一点: 直线相交的模板 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include &l…
链接:http://poj.org/problem?id=1066 Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5431   Accepted: 2246 Description Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid…
题意:给定4个点的坐标,前2个点是一条线,后2个点是另一条线,求这两条线的关系,如果相交,就输出交点. 题解:先判断是否共线,我用的是叉积的性质,用了2遍就可以判断4个点是否共线了,在用斜率判断是否平行,最后就是相交了,求交点就好了. 求交点的过程和高中知识差不多,用y=kx+c来求,只不过要注意斜率不存在的时候特殊处理,还有就是求斜率的时候一定要强制转换,(坑爹的我,调试了一小时才找到这个bug) AC代码: #include <map> #include <set> #incl…
题目链接:http://poj.org/problem?id=1269 题目大意:给出四个点的坐标x1,y1,x2,y2,x3,y3,x4,y4,前两个形成一条直线,后两个坐标形成一条直线.然后问你是否平行,重叠或者相交,如果相交,求出交点坐标. 算法:二维几何直线相交+叉积 解法:先用叉积判断是否相交,如果相交的话,设交点坐标为p0(x0,y0).向量(p0p1)和(p0p2)的叉积为0,有(x1-x0)*(y2-y0)-(y1-y0)*(x2-x0)=0;同理,求出p0和p3p4直线的式子.…
Geometric Shapes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 1243   Accepted: 524 Description While creating a customer logo, ACM uses graphical utilities to draw a picture that can later be cut into special fluorescent materials. To…