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< ...
随机推荐
- Java中JIN机制及System.loadLibrary() 的执行过程
Android平台Native开发与JNI机制详解 http://mysuperbaby.iteye.com/blog/915425 个人认为下面这篇转载的文章写的很清晰很不错. 注意Android平 ...
- decimal to hexadecimal,binary and octonary.
Here is a simple algorithm about 'decimal' to 'dexadecimal',and the implementation code: /* Convert ...
- 外部式css样式,写在单独的一个文件中
外部式css样式(也可称为外联式)就是把css代码写一个单独的外部文件中,这个css样式文件以“.css”为扩展名,在<head>内(不是在<style>标签内)使用<l ...
- 纯命令行教你Cocoapods的安装和使用
关于cocoapods的介绍和作用,网上有很多大神介绍的比我清楚,建议去看一下唐巧的http://blog.devtang.com/blog/2014/05/25/use-cocoapod-to-ma ...
- 关于c:\fakepath\的解决办法
(2014.11.25 最后更新) 一.碎碎念:关于访问本地图片的路径的问题,比较典型的例子就是上传头像.在以往的解决办法中,我们大多是先将图片上传到服务器然后从服务器返回图片,显示在页面上以达到预览 ...
- cocos2dx解析lua table数据结构 简易版.
之前一直用xml填配置, cocos2dx自带了xml解析接口, 非常方便. 但是, 接口好用也改变不了xml的结构字符太多, 书写麻烦, 乱七八糟的事实. 很早就想换lua, 无奈引擎没有现成接口, ...
- SGU 139.Help Needed!
题意: 判断15数码问题是否有解. 如果0的偏移量和逆序对个数同奇偶则无解. 因为目标状态的偏移量为0,逆序对为15,而0移动的时候偏移量±1,逆序对的改变量为也为奇数. 这就使得偏移量和逆序对数始终 ...
- 【POJ2887】【块状链表】Big String
Description You are given a string and supposed to do some string manipulations. Input The first lin ...
- Java jdk环境搭建
java JDK的配置在我的电脑环境变量中配置: 主要的配置参数path 例:path = C:\jdk1.7.0_13\bin ; 另外一个JAVA_HOME 例:JAVA_HOME = C:\j ...
- 在CentOS 7中轻松安装Atomic应用(atomicapp)
sudo yum install docker atomic etcd kubernetes sudo systemctl enable docker.service sudo systemctl s ...