poj1673EXOCENTER OF A TRIANGLE
据说这题是垂心。。数学太弱没有看出来,写了分朴实无华的代码。。
旋转三边得到图中的外顶点,然后连接三角形顶点求交点,交上WA。。觉得没什么错误就去看了下discuss,发现都在说精度问题,果断开始水,最后+了epsAC了。。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y) {}
}p[];
typedef Point pointt;
pointt operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y);
}
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
Point rotate(Point a,double rad)
{
return Point(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));
}
bool intersection1(Point p1, Point p2, Point p3, Point p4, Point& p) // 直线相交
{
double a1, b1, c1, a2, b2, c2, d;
a1 = p1.y - p2.y;
b1 = p2.x - p1.x;
c1 = p1.x*p2.y - p2.x*p1.y;
a2 = p3.y - p4.y;
b2 = p4.x - p3.x;
c2 = p3.x*p4.y - p4.x*p3.y;
d = a1*b2 - a2*b1;
if (!dcmp(d)) return false;
p.x = (-c1*b2 + c2*b1) / d;
p.y = (-a1*c2 + a2*c1) / d;
return true;
}
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
double mul(Point p0,Point p1,Point p2)
{
return cross(p1-p0,p2-p0);
}
int main()
{
int n,i;
cin>>n;
while(n--)
{
for(i = ; i <= ; i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
Point p1,p2,p3,p4;
if(dcmp(mul(p[],p[],p[]))>)
{
p1 = rotate(p[]-p[],*pi/2.0);
p2 = rotate(p[]-p[],pi/2.0);
}
else
{
p1 = rotate(p[]-p[],pi/2.0);
p2 = rotate(p[]-p[],*pi/2.0);
}
p1.x+=p[].x;
p1.y+=p[].y;
p2.x+=p[].x;
p2.y+=p[].y;
p1.x = (p1.x+p2.x)/;
p1.y = (p1.y+p2.y)/; if(dcmp(mul(p[],p[],p[]))>)
{
p3 = rotate(p[]-p[],*pi/2.0);
p4 = rotate(p[]-p[],pi/2.0);
}
else
{
p3 = rotate(p[]-p[],pi/2.0);
p4 = rotate(p[]-p[],*pi/2.0);
}
p3.x+=p[].x;
p3.y+=p[].y;
p4.x+=p[].x;
p4.y+=p[].y;
p3.x = (p3.x+p4.x)/;
p3.y = (p3.y+p4.y)/;
Point pp ;
intersection1(p1,p[],p3,p[],pp);
printf("%.4f %.4f\n",pp.x+eps,pp.y+eps); }
return ;
}
poj1673EXOCENTER OF A TRIANGLE的更多相关文章
- [LeetCode] Triangle 三角形
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
- [LeetCode] Pascal's Triangle II 杨辉三角之二
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...
- [LeetCode] Pascal's Triangle 杨辉三角
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...
- 【leetcode】Pascal's Triangle II
题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...
- 【leetcode】Pascal's Triangle
题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...
- POJ 1163 The Triangle(简单动态规划)
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- Triangle - Delaunay Triangulator
Triangle - Delaunay Triangulator eryar@163.com Abstract. Triangle is a 2D quality mesh generator an ...
- LeetCode 118 Pascal's Triangle
Problem: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows ...
- LeetCode 119 Pascal's Triangle II
Problem: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Ret ...
随机推荐
- SQLServer学习笔记<> 表连接查询----交叉连接、内连接、左连接、右连接
(1)交叉连接(cross join)即我们所说的笛卡尔积.查询出满足两张表所有的记录数,A(3条记录),B(9条记录),A*B(27条记录). 比如:雇员表(HR.employees)和货运公司(S ...
- oracle进制-10进制跟2进制互转
CREATE OR REPLACE FUNCTION NUMBER_TO_BIT(V_NUM NUMBER) RETURN VARCHAR IS V_RTN );--注意返回列长度 V_N1 NUMB ...
- JavaScript DOM 编程艺术(第2版)读书笔记 (7)
动态创建标记 一些传统方法 document.write document.write()方法可以方便快捷的把字符串插入到文档里. 请把以下标记代码保存为一个文件,文件名就用test.html 好了. ...
- easyui datagrid 可过滤行的数据表格 导出
//过滤栏表格导出数据 /* xukf * id datagrid id * url Action 路 ...
- 通过PowerShell查看Android端log信息
在Windows下我们可以通过在cmd中输入adb logcat相关命令来查看安卓设备上的log信息,这在PowerShell里也可以做到.所以方便做成一个脚本,以便复用.代码如下: function ...
- iOS高仿app源码:纯代码打造高仿优质《内涵段子》
iOS高仿app源码:纯代码打造高仿优质<内涵段子>收藏下来 字数1950 阅读4999 评论173 喜欢133 Github 地址 https://github.com/Charlesy ...
- Mybaits 之根据集合查询和逗号分隔的子查询
这是我们的mapper要根据传入一个集合进行查询: List<ExtKeywordCategory> findListByIds(List<ExtKeywordFkCategory& ...
- Java中的的XML文件读写
XML简介 要理解XML,HTML等格式,先来理解文档对象模型DOM 根据 DOM,HTML 文档中的每个成分都是一个节点,这些节点组成了一棵树.DOM 是这样规定的:整个文档是一个文档节点每个 HT ...
- 2016 ACM/ICPC Asia Regional Qingdao Online HDU5889
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5889 解法:http://blog.csdn.net/u013532224/article/details ...
- Jnotify文件监控的用法以及Jar文件导入的方法
简介Jnotiy, 支持动态监控(支持级联监控)文件夹和文件的jar包.在linux中,调用linux底层的jnotify服务.在windows中,需要添加附件的dll文件. 因为通用的Maven仓库 ...