poj 1269 水题
题目链接:http://poj.org/problem?id=1269
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn = ;
const int maxe = ;
const int INF = 0x3f3f3f;
const double eps = 1e-;
const double PI = acos(-1.0); struct Point{
double x,y;
Point(double x=, double y=) : 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(A.x*p,A.y*p);}
Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){
return a.x < b.x ||( a.x == b.x && a.y < b.y);
}
int dcmp(double x){
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b){
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; }
double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; }
double Length(Vector A) { return sqrt(Dot(A,A)); } Point GetLineIntersecion(Point P, Vector v,Point Q,Vector w){
Vector u = P - Q;
double t = Cross(w,u)/Cross(v,w);
return P + v*t;
} Point read_point(){
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
} /******************************分割线*******************************/ Point P1,P2,Q1,Q2;
int N; int main()
{
// freopen("E:\\acm\\input.txt","r",stdin);
cin>>N;
printf("INTERSECTING LINES OUTPUT\n");
while(N--){
P1 = read_point();
P2 = read_point();
Q1 = read_point();
Q2 = read_point();
if(dcmp(Cross(P2-P1,Q2-Q1))==){ //平行或重合;
if(dcmp(Cross(P1-Q1,P1-Q2)) == ) printf("LINE\n");
else printf("NONE\n");
}
else{ //相交;
Point A = GetLineIntersecion(P1,P2-P1,Q1,Q2-Q1);
printf("POINT %.2f %.2f\n",A.x,A.y);
}
}
printf("END OF OUTPUT\n");
}
poj 1269 水题的更多相关文章
- poj 2245 水题
求组合数,dfs即可 #include<cstdio> #include<iostream> #include<algorithm> #include<cst ...
- poj 1298(水题)
The Hardest Problem Ever Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24241 Accept ...
- poj 3006水题打素数表
#include<stdio.h> #include<string.h> #define N 1100000 int isprim[N],prime[N]; void ispr ...
- POJ 3672 水题......
5分钟写完 水水更开心 //By SiriusRen #include <cstdio> #include <iostream> #include <algorithm& ...
- POJ 1269 Intersecting Lines(线段相交,水题)
id=1269" rel="nofollow">Intersecting Lines 大意:给你两条直线的坐标,推断两条直线是否共线.平行.相交.若相交.求出交点. ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
- POJ 水题若干
POJ 3176 Cow Bowling 链接: http://poj.org/problem?id=3176 这道题可以算是dp入门吧.可以用一个二维数组从下向上来搜索从而得到最大值. 优化之后可以 ...
- poj 3080 Blue Jeans(水题 暴搜)
题目:http://poj.org/problem?id=3080 水题,暴搜 #include <iostream> #include<cstdio> #include< ...
随机推荐
- express不是内部命令解决办法
安装nodejs后,安装express,cmd下命令:npm install express -g;之后敲入express -V会提示不是内部命令,是因为, 4.0版本中将命令工具分家出来了,所以我们 ...
- CoreBluetooth
Core Bluetooth的基本常识 每个蓝牙4.0设备都是通过服务(Service)和特征(Characteristic)来展示自己的 一个设备必然包含一个或多个服务,每个服务下面又包含若干个特征 ...
- IE6 png兼容问题
1.IE6 png <!--[if IE 6]> <script src="../js/png.js" type="text/javascript& ...
- C# 线程间互相通信
C#线程间互相通信主要用到两个类:AutoResetEvent和ManualResetEvent. 一.AutoResetEvent AutoResetEvent 允许线程通过发信号互相通信,线程通过 ...
- Fedora 21 安装Infinality
原文地址: Fedora 21 用infinality美化你的字体 http://blog.csdn.net/element207/article/details/41746683 安装infinal ...
- 网页main中左边固定宽度,右边自适应。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Ajax基础--JavaScript实现
ajax原理 1.ajax 即“Asynchronous JavaScript and XML”(异步 JavaScript 和 XML),也就是无刷新数据读取. 通俗地讲就是:AJAX 通过在后台与 ...
- PHP中截取中文乱码
大家都知道,一个汉字在gb2312下面是占2个字节,用传统的substr肯定会出问题 ,所以应该用,mb_substr和mb_strcut两个函数 在这个之前,打开php.ini打开php_mbstr ...
- 百度的一个Ajax跨域方法 JavaScript是没有域的限制
baidu的通行证处理都是在二级域名passport.baidu.com中处理的,但是baidu很多地方登录都好像是用ajax处理的,他是怎么做的呢?研究了一下,发现一个小技巧. 在http://zh ...
- unix-环境高级编程-读书笔记与习题解答-第三篇
第一章 第五节 进程与控制 该小节比较粗略的阐述了unix操作系统中用于进程控制的三个函数,分别为 : fork , exec, waitpid, 其中 exec 有五种变体, 这些变体实现的功能全部 ...