POJ1269(计算几何基础-直线与直线之间的关系与它们的交点)

PE启动盘结合360杀毒离线版:深度清除顽固病毒实战指南 在系统安全维护领域,离线查杀是一种在独立于宿主操作系统的环境下进行病毒扫描和清除的核心技术。其原理是通过一个预启动环境(如PE)加载杀毒软件,从而绕过可能已被感染或受保护的系统核心,直接访问和扫描磁盘文件。这项技术的核心价值在于能够彻底处理那些在正常系统运行时难以清除的深度隐藏病毒、Rootkit和驱动级木马。典型的应用场景包括应对勒索软件、顽固感染型病毒以及系统启动项被劫持等情况。本文以“PE启动盘”和“360杀毒离线版”这一经典组合为例,详细解析了从工具选型、环境部署到深度查杀策略的全流程,为系统维护人 阅读详情

Intersecting Lines
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 16216 Accepted: 7001
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 one another (i.e. they are the same line), 3) intersect in a point. In this problem you will use your algebraic knowledge to create a program that determines how and where two lines intersect.
Your program will repeatedly read in four points that define two lines in the x-y plane and determine how and where the lines intersect. All numbers required by this problem will be reasonable, say between -1000 and 1000.
Input

The first line contains an integer N between 1 and 10 describing how many pairs of lines are represented. The next N lines will each contain eight integers. These integers represent the coordinates of four points on the plane in the order x1y1x2y2x3y3x4y4. Thus each of these input lines represents two lines on the plane: the line through (x1,y1) and (x2,y2) and the line through (x3,y3) and (x4,y4). The point (x1,y1) is always distinct from (x2,y2). Likewise with (x3,y3) and (x4,y4).
Output

There should be N+2 lines of output. The first line of output should read INTERSECTING LINES OUTPUT. There will then be one line of output for each pair of planar lines represented by a line of input, describing how the lines intersect: none, line, or point. If the intersection is a point then your program should output the x and y coordinates of the point, correct to two decimal places. The final line of output should read “END OF OUTPUT”.
Sample Input

5
0 0 4 4 0 4 4 0
5 0 7 6 1 0 2 3
5 0 7 6 3 -6 4 -3
2 0 2 27 1 5 18 5
0 3 4 0 1 2 2 5
Sample Output

INTERSECTING LINES OUTPUT
POINT 2.00 2.00
NONE
LINE
POINT 2.00 5.00
POINT 1.07 2.20
END OF OUTPUT
Source

Mid-Atlantic 1996

题意:每次给你两条直线,问你这两条直线的关系是重合还是平行还是相交,如果是相交,则输出它们的交点。

解题思路:用向量的叉积来做就行,套一套模板。注意用g++交可能过不了,用c++交。

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const double eps = 1e-9;
struct Point{
    double x, y;
    Point(double _x = 0, double _y = 0){
        x = _x;
        y = _y;
    }
};
typedef Point Vector;
Vector operator +(Vector A, Vector B) {return Vector(A.x + B.x, A.y + B.y);}//向量加
Vector operator -(Vector A, Vector B) {return Vector(A.x - B.x, A.y - B.y);}//向量减
Vector operator *(Vector A, double p) {return Vector(p * A.x, p * A.y);}//向量的数乘
Vector operator /(Vector A, double p) {return Vector(A.x / p, A.y / p);}//向量的数除
Vector operator -(Vector A) {return Vector(-A.x, -A.y);}//向量的取反
int dcmp(double x)
{
    if(fabs(x) < eps) return 0;
    else return x < 0 ? -1 : 1;
}
bool operator == (const Point& a, const Point& b) {
    return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
}
double Cross(Vector A, Vector B)//求解向量叉积
{
    return A.x * B.y - A.y * B.x;
}
double Dot(Vector A, Vector B)//求解向量数量积
{
    return A.x * B.x + A.y * B.y;
}
double xmulti(Point p, Point a, Point b)//求向量pa叉乘pb
{
    return (a.x - p.x) * (b.y - p.y) - (a.y - p.y) * (b.x - p.x);
}
struct Line{
    Point p1;
    Point p2;
    Line(Point _p1, Point _p2){
        p1 = _p1;
        p2 = _p2;
    }
    Line(){
        p1 = Point(0, 0);
        p2 = Point(0, 0);
    }
};
typedef Line seg;
int line_loc(Line l1, Line l2)//判断直线的位置关系,1为平行,0为重合,-1为相交
{
    Point p1 = l1.p1;
    Point p2 = l1.p2;
    Point p3 = l2.p1;
    Point p4 = l2.p2;
    Vector v1 = p2 - p1;
    Vector v2 = p4 - p3;
    Vector v3 = p3 - p1;
    double d1 = Cross(v1, v2);
    double d2 = Cross(v1, v3);
    if(dcmp(d1) == 0 && dcmp(d2) == 0) return 0;//重合
    else if(dcmp(d1) == 0) return 1;
    else return -1;
}
Point seg_intersecting(Line l1, Line l2)//求两相交的直线(线段也一样)的交点
{
    Point A = l1.p1;
    Point B = l1.p2;
    Point C = l2.p1;
    Point D = l2.p2;
    double _x, _y;
    _x = (xmulti(A, B, D) * C.x - xmulti(A, B, C) * D.x) / (xmulti(A, B, D) - xmulti(A, B, C));
    _y = (xmulti(A, B, D) * C.y - xmulti(A, B, C) * D.y) / (xmulti(A, B, D) - xmulti(A, B, C));
    return Point(_x, _y);
}
int main()
{
    int T;
    scanf("%d", &T);
    Line L1, L2;
    cout<<"INTERSECTING LINES OUTPUT"<<endl;
    while(T--)
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &L1.p1.x, &L1.p1.y, &L1.p2.x, &L1.p2.y, &L2.p1.x, &L2.p1.y, &L2.p2.x, &L2.p2.y);
        int ans = line_loc(L1, L2);
        if(ans == 0) cout<<"LINE"<<endl;
        else if(ans == 1) cout<<"NONE"<<endl;
        else
        {
            Point res = seg_intersecting(L1, L2);
            cout<<"POINT";
            printf(" %.2lf %.2lf\n", res.x, res.y);
        }
    }
    cout<<"END OF OUTPUT"<<endl;
    return 0;
}

Linux -- Tomcat 8.5.55 版本的下载与升级 安全扫描出现如下漏洞: Apache Tomcat 7.0.100之前的7.*版本、8.5.51之前的8.*版本和9.0.31之前的9.*版本中的Tomcat AJP协议存在文件包含漏洞。攻击者可利用该漏洞读取或包含Tomcat上所有 webapp目录下的任意文件,如:webapp 配置文件或源代码等 Apache Tomcat 9.0.0.M1版本至9.0.29版本、8.5.0版本至8.5.49版本和7.0.0版本至7.0.98版本中存在授权问题漏洞。该漏洞源于网络系统或产品中缺少身份验证措施或身份验 阅读详情

相关推荐

51单片机-点亮LED和蜂鸣器

ULN2003是高耐压、大电流达林顿陈列,由七个硅NPN达林顿管组成。ULN2003是大电流驱动陈列,多用于单片机、只能仪表、PLC、数字量输出卡等控制电路中。可直接驱动蜂鸣器、继电器等负载。void delay(u16 i) // i等于1大约10uswhile(i--);//取反,高低电平不断变化,产生脉冲delay(10);// 周期200us。

三日沐水 1139

poj 1263 Reflections (计算几何 反射)

题目意思:给出几个圆,再给出一个光源点和方向,模拟反射过程 解题思路: 1.求出射线; 2.求出在这条射线方向与圆的第一个交点,也就判断出是哪个圆; 3.把交点做为光源,求对称点,再反回步骤1。 难点在第二步,即要判断是否有两个交点(题目中已给出没有一个交点的情况) 还要判断这个交点是否是离光源最近的一点(不是刚反射过的那个圆),      还有要注意的是这是射线,不是直线,求出交点

三思 938

网络工程系统CAD图:从设计到落地的关键技能与实战指南

网络工程并不只是配置路由器和交换机,真正的核心在于将设计方案转化为可施工的物理图纸。网络工程系统CAD图正是连接逻辑设计与物理世界的桥梁,它涵盖综合布线、信息点布置、桥架路由、弱电间规划等关键内容。理解并掌握这套图纸体系,是网络工程师从基础设备调试走向项目主导者、弱电总工乃至网络架构师的重要分水岭。在园区网、数据中心、智能楼宇等真实场景中,一套规范的系统CAD图直接决定了施工质量、验收效率与后期运维的可靠性。本文从基础概念出发,拆解图纸的组成层次、绘制流程和软件工作流,并结合学习路线与就业方向,帮助初学者建

weixin_33860553的博客 401

计算几何学习笔记之点和直线

向量的基本运算http://blog.csdn.net/cqbzwja/article/details/51030712 直线用参数方程表示,参数方程就是直线上任意一点,加上一个方向向量,以及参数t。假设直线上所有点满足P=P0+tv⃗ P = P_0+t\vec v,那么t为参数,P0是直线上任意一点,v是直线的方向。假设点Q有Q=P0+t0v⃗ Q = P_0+t_0\vec v,则表示Q在P

ACMer_quack&cheer 1423

LPDDR5时序精调:深入解析Read Gate Training的两种模式

本文深入解析了LPDDR5内存中关键的Read Gate Training技术,详细对比了RDQS Toggle Mode(翻转模式)与Enhanced RDQS Mode(增强模式)的工作原理、时序参数及适用场景。文章阐述了在高速数据传输下精准校准时序的必要性,并提供了两种模式的实战选型指南与系统级调试思路,帮助工程师优化内存性能与稳定性。

weixin_29219189的博客 383

多目标优化NSGA-II(快速精英非支配排序遗传算法)及python实现

文章目录前言一、什么是NSGA-II?二、学习NSGA-II1.快速非支配排序算法2.密度估计3.拥挤比较算子4.主循环5.代码6.总结 前言 NSGA-II适用于复杂的多目标优化问题,是K-Deb教授在2000年在一篇paper《MOEAs — A fast and elitist multi-objective genetic algorithm: nsga2》提出。 Keywords: optimization; multi-objective evolutionary algorithm; no

ricky_blog 9765

判断两条直线的夹角

      /// &lt;summary&gt;        /// 判断要素是否平行        /// &lt;/summary&gt;        /// &lt;returns&gt;&lt;/returns&gt;        protected bool GeometryParallel(IFeature pFeat,out Lineside pSide)        { ...

study_gis的专栏 5022

物流分拣YOLO实战:YOLO26 OBB+YOLOv8多尺度融合,不规则包裹分拣效率提升40%(附训练+部署代码)

在物流分拣的工业场景中,模型的检测精度、推理速度、部署友好性本次基于YOLO26 OBB+YOLOv8多尺度融合打造的物流分拣视觉检测方案,精准解决了工业场景中不规则包裹的旋转检测、多尺度包裹的漏检问题,最终实现分拣效率提升40%,检测准确率提升至95%以上,且模型在边缘设备上的推理帧率稳定35FPS+,完全适配物流分拣的工业落地需求。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 889

poj 1269 Intersecting Lines

Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u [Submit]

codeStone 1020

安卓讲课笔记1.1 安装Android Studio

1. 能安装配置Android Studio; 2. 能创建安卓虚拟机(AVD); 3. 能创建简单安卓应用

howard2005的专栏 3556

通过Robotstudio修改机器人程序的具体方法和步骤

通过Robotstudio修改机器人程序的具体方法和步骤

Robot_PLC_HMI_Automation 6415

Intersecting Lines (计算几何基础+判断两直线的位置关系)

题目链接:http://poj.org/problem?id=1269 题面: 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...

di6499的博客 237

使用MATLAB进行灰色预测 GM(1,1)

使用MATLAB进行灰色预测 GM(1,1)

Hou_____的博客 1006

POJ 1269 Intersecting Lines(简单计算几何 · 直线与直线的位置关系)

一、传送门 http://poj.org/problem?id=1269 二、算法分析说明 三、代码 #include<cstdio> #include<cmath> #pragma warning(disable:4996) template<class _Ty> struct point { _Ty x, y; }; unsigned n; point&l...

COFACTOR 244

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

计算几何——直线交点poj1269

求直线交点还是要推一个公式的。。 见博客https://blog.csdn.net/u013050857/article/details/40923789 还要学一下向量的定点比分法 另外poj精度好像卡的厉害,zoj1280就没啥问题 #include<iostream> #include<cstring> #include<cstdio> ...

weixin_30384031的博客 117

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

【计算几何】【直线交点】Intersecting Lines

POJ 1269 至今不明白为什么POJ中把G++改成C++就对了 题目: 求两直线的关系,若相交求其交点 题解: #include<cstdio> #include<cmath> #include<string.h> #include<iostream> using namespace std; const int N=1e3+10; const ...

ygmjsjdboy的博客 252

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

【计算几何】POJ 1269 Intersecting Lines

POJ 1269 Intersecting Lines【传送门】 Intersecting Lines Time Limit:1000MS Memory Limit:10000K Total Submissions:20497 Accepted:8658 Description We all know that a pair of disti...

lesileqin的博客 222

POJ 1269 Intersecting Lines (两直线位置关系+求交点)

题意:给出两直线位置,求是平行、重合还是有交点,若有交点,输出。 题解:两直线位置关系+求交点 套板子。 #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<queue> #include<stack> #inclu

gongyuandaye的博客 236

Intersecting Lines POJ 1269(计算几何+判断直线间关系+求直线的交点)

Intersecting LinesPOJ - 1269 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 intersectio...

勉強しているユキさんです 597

POJ1269 简单的计算几何判断直线相交

Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8898   Accepted: 4003 Description We all know that a pair of distinct points on a plane defi

没错就是这样 745

ACM-计算几何之Intersecting Lines——poj1269

ACM 计算几何 Intersecting Lines poj1269

继续激情,继续奋斗。 2354

(计算几何)POJ1269Intersecting Lines

POJ1269Intersecting Lines 题意: 给你两条直线,相交输出交点,重合输出“LINE”,平行输出“NONE”。 思路: 直线相交的模板题,就是在平行和重合的时候可以用叉乘判断。 注意点: 提交G++的时候,不要用%.2lf,要用%.2f。 代码: #include<iostream> #include<stdio.h> #include<stdlib.h> #include<algorithm> #include<string.h&

Z7784562的博客 231

POJ-1269 直线相交的判断及交点

题意: 给了两个线段的两个端点的坐标。求他们相交的类型,如果正规相交并求出交点。 分析: 用点叉积,可以判断线段的相交类型(平行,共线,相交).大概是:  如果相交:设交点:p0(x0,y0),根据交点在两个线段上有方程:    (p1-p0)X(p2-p0)=0;    (p3-p0)X(p4-p0)=0; 展开就行了。 看代码就知道了: #include #include u

ZXLS-ZMR的专栏 853

POJ 1269 求两直线交点

题意:给出4个点,两个一组在两条直线上,求出这两条直线的重合部分,NONE就是平行,LINE就是重合,POINT就是有交点并且输出交点。 解析几何那么求,没什么好说的直接看代码吧。 #include #include #include using namespace std; typedef double PointType; struct point { PointType x,y

韩小侠的专栏 已迁移至lssea.com 622

【POJ】1269 Intersecting Lines(计算几何基础)

http://poj.org/problem?id=1269 我会说这种水题我手推公式+码代码用了1.5h? 还好新的一年里1A了~~~~ #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostrea...

78

Intersecting Lines POJ - 1269

http://poj.org/problem?id=1269 叉积真的是计算几何利器 首先对于两条直线(p1 p2) (p3 p4) 若两直线共线 则p3-p1与p2-p1的叉积模为0且p4-p1与p2-p1的叉积模为0 否则 用斜率判一下平行 最后 如果相交求交点 设交点为p0 则p1-p0与p2-p0的叉积模为0p3-p0与p4-p0的叉积模为0 联立后可得a1*x+b1*y+c1...

sunyutian1998的博客 240
上一篇: POJ3304(计算几何基础-判断线段与直线相交)
下一篇: POJ3321(dfs序+树状数组)
creatorx
博客等级 码龄10年 127粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址