不知道谁转的计算几何题集里面有这个题...标题还写的是基本线段求交...

结果题都没看就直接敲了个线段交...各种姿势WA一遍以后发现题意根本不是线段交而是直线交...白改了那个模板...

乱发文的同学真是该死...浪费我几个小时的生命...

/********************* Template ************************/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std; #define EPS 1e-8
#define MAXN (int)5e5+5
#define MOD (int)1e9+7
#define PI acos(-1.0)
#define LINF ((1LL)<<50)
#define INF (1<<30)
#define DINF (1e10)
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max3(a,b,c) (max(max(a,b),c))
#define min3(a,b,c) (min(min(a,b),c))
#define BUG cout<<"BUG! "<<endl
#define LLL cout<<"--------------"<<endl
#define L(t) (t << 1)
#define R(t) (t << 1 | 1)
#define Mid(a,b) ((a + b) >> 1)
#define lowbit(a) (a & -a)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#pragma comment (linker,"/STACK:102400000,102400000") // typedef long long LL;
// typedef unsigned long long ULL;
// typedef __int64 LL;
// typedef unisigned __int64 ULL;
// int gcd(int a,int b){ return b?gcd(b,a%b):a; }
// int lcm(int a,int b){ return a*b/gcd(a,b); } /********************* F ************************/
struct POINT{
double x,y;
POINT(double _x = , double _y = ):x(_x),y(_y){};
};
bool operator == (POINT a,POINT b){
if(a.x == b.x && a.y == b.y) return true;
return false;
}
struct LINE{
POINT a,b;
double K,B;
LINE(POINT _a = ,POINT _b = ):a(_a),b(_b){
if((a.x - b.x) == ){
K = DINF;
B = a.x;
}else{
K = ((a.y - b.y) / (a.x - b.x));
B = (- (b.x * a.y - a.x * b.y) / (a.x - b.x));
}
} };
double dist(POINT p1,POINT p2){
return(sqrt((p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y)));
}
double multiply(POINT sp,POINT ep,POINT op){
return (sp.x-op.x) * (ep.y-op.y) - (ep.x-op.x) * (sp.y-op.y);
}
bool cross_Judge(LINE a ,LINE b) {
double x = multiply(a.a,a.b,b.a);
double y = multiply(a.a,a.b,b.b);
if(x == && y != ) return true;
if(x != && y == ) return true;
return (x * y < );
}
bool same(LINE a , LINE b) {
if(a.a == b.a && a.b == b.b) return true;
if(a.b == b.a && a.a == b.b) return true;
return false;
}
bool onseg(POINT a,POINT s,POINT e){
if(multiply(a,s,e) == && a.x <= max(s.x,e.x) && a.x >= min(s.x,e.x)
&& a.y <= max(s.y,e.y) && a.y >= min(s.y,e.y))
return true;
return false;
}
bool cover(LINE a , LINE b) {
if(multiply(a.a,a.b,b.a) == && multiply(a.a,a.b,b.b) == ){
if(onseg(a.a,b.a,b.b) || onseg(a.b,b.a,b.b)) return true;
if(onseg(b.a,a.a,a.b) || onseg(b.b,a.a,a.b)) return true;
}else return false;
}
bool cross(LINE a , LINE b){
if(min(a.a.x,a.b.x) > max(b.a.x,b.b.x)) return false;
if(min(b.a.x,b.b.x) > max(a.a.x,a.b.x)) return false;
if(min(a.a.y,a.b.y) > max(b.a.y,b.b.y)) return false;
if(min(b.a.y,b.b.y) > max(a.a.y,a.b.y)) return false;
return (cross_Judge(a,b) && cross_Judge(b,a));
}
int main()
{
//FIN;
int n ;
cin>>n;
cout<<"INTERSECTING LINES OUTPUT"<<endl;
for(int i = ; i < n ; i++){
double a,b,c,d,e,f,g,h;
cin>>a>>b>>c>>d>>e>>f>>g>>h;
LINE x = LINE(POINT(a,b),POINT(c,d));
LINE y = LINE(POINT(e,f),POINT(g,h));
if(multiply(x.a,x.b,y.a) == && multiply(x.a,x.b,y.b) == ){
cout<<"LINE"<<endl;
continue;
}else if(x.K == y.K && x.B != y.B){
cout<<"NONE"<<endl;
continue;
}else{
cout<<"POINT ";
if(x.K == DINF){
printf("%.2lf %.2lf\n",x.B,x.B * y.K + y.B);
}else if(y.K == DINF) {
printf("%.2lf %.2lf\n",y.B,y.B * x.K + x.B);
}else {
double cx = (x.B-y.B) / (y.K-x.K);
double cy = x.K * cx + x.B;
printf("%.2lf %.2lf\n",cx,cy);
}
continue;
}
}
cout<<"END OF OUTPUT"<<endl;
return ;
}

POJ 1269 Intersecting Lines 直线交的更多相关文章

  1. POJ 1269 - Intersecting Lines 直线与直线相交

    题意:    判断直线间位置关系: 相交,平行,重合 include <iostream> #include <cstdio> using namespace std; str ...

  2. poj 1269 Intersecting Lines(直线相交)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8637   Accepted: 391 ...

  3. POJ 1269 Intersecting Lines(判断两直线位置关系)

    题目传送门:POJ 1269 Intersecting Lines Description We all know that a pair of distinct points on a plane ...

  4. POJ 1269 Intersecting Lines (判断直线位置关系)

    题目链接:POJ 1269 Problem Description We all know that a pair of distinct points on a plane defines a li ...

  5. 判断两条直线的位置关系 POJ 1269 Intersecting Lines

    两条直线可能有三种关系:1.共线     2.平行(不包括共线)    3.相交. 那给定两条直线怎么判断他们的位置关系呢.还是用到向量的叉积 例题:POJ 1269 题意:这道题是给定四个点p1, ...

  6. poj 1269 Intersecting Lines——叉积求直线交点坐标

    题目:http://poj.org/problem?id=1269 相关知识: 叉积求面积:https://www.cnblogs.com/xiexinxinlove/p/3708147.html什么 ...

  7. POJ 1269 Intersecting Lines【判断直线相交】

    题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0) ...

  8. 简单几何(直线位置) POJ 1269 Intersecting Lines

    题目传送门 题意:判断两条直线的位置关系,共线或平行或相交 分析:先判断平行还是共线,最后就是相交.平行用叉积判断向量,共线的话也用叉积判断点,相交求交点 /********************* ...

  9. POJ 1269 Intersecting Lines(直线相交判断,求交点)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8342   Accepted: 378 ...

随机推荐

  1. 虚拟机: 虚拟机win7的激活方式(底层操作系统 为 win10) ===用windows loader

    激活方式:  需要用windows loader

  2. 洛谷 P1604 B进制星球

    P1604 B进制星球 题目背景 进制题目,而且还是个计算器~~ 题目描述 话说有一天,小Z乘坐宇宙飞船,飞到一个美丽的星球.因为历史的原因,科技在这个美丽的星球上并不很发达,星球上人们普遍采用B(2 ...

  3. Nutch1.6学习笔记

    回 到 目 录 暑假每天傍晚或晚上更新 伪恋赛高 这里提供nutch1.6的src下载: apache-nutch-1.6-src.zip 115网盘礼包码:5lbcymlo6u76http://11 ...

  4. Android 连接网络数据库的方式

    以连接MS SQL(sqlserver数据库)的网络数据库为例,从当前搜集的资料来看,一共有两种方式:在Android工程中引入JDBC驱动,直接连接:通过WebService等方法的间接连接. 采用 ...

  5. oracle之ROWNUM的查询应用

    1 在ORACLE数据库中,ROWNUM是ORACLE数据库为查询结果加入的一个伪列.起始值为1.经常使用来处理查询结果的分页. 2 因为ROWNUM的特殊性,使用时候一般是分三层: 第一层:先进行查 ...

  6. HNU13303 Counting substhreengs(递推)

    题目:http://acm.hnu.cn/online/? action=problem&type=show&id=13303&courseid=0 题意:给你一个字符串,由数 ...

  7. Qt creator 编译错误 :cannot find file .pro qt

    事实上问题的解决的方法非常easy:就是Qt不支持中文的路径,把源代码的路径所有改成英文就可以解决这个问题. 首先问题发生在我执行网上的样例程序时,又一次构建编译也是出错.提示: Cannot fin ...

  8. FSM的几种策略

    FSM是什么?FSM就是Finite(有限) State(状态) 机(Machine)的缩写.(之所以中英文混写,是为了强调学懂FSM的原理是根本,刻意去采用“几段式”的写法并不重要) riple F ...

  9. pandas 下的 one hot encoder 及 pd.get_dummies() 与 sklearn.preprocessing 下的 OneHotEncoder 的区别

    sklearn.preprocessing 下除了提供 OneHotEncoder 还提供 LabelEncoder(简单地将 categorical labels 转换为不同的数字): 1. 简单区 ...

  10. OPENCV(4) —— ImgProc

    2D图像滤波器基础类BaseFilter:dst(x,y) = F(src(x,y), src(x+1,y)... src(x+wdith-1,y), src(y+1,x)... src(x+widt ...