链接

据说这题是垂心。。数学太弱没有看出来,写了分朴实无华的代码。。

旋转三边得到图中的外顶点,然后连接三角形顶点求交点,交上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的更多相关文章

  1. [LeetCode] Triangle 三角形

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  2. [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, ...

  3. [LeetCode] Pascal's Triangle 杨辉三角

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  4. 【leetcode】Pascal's Triangle II

    题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...

  5. 【leetcode】Pascal's Triangle

    题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...

  6. POJ 1163 The Triangle(简单动态规划)

    http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  7. Triangle - Delaunay Triangulator

    Triangle - Delaunay Triangulator  eryar@163.com Abstract. Triangle is a 2D quality mesh generator an ...

  8. LeetCode 118 Pascal's Triangle

    Problem: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows  ...

  9. 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 ...

随机推荐

  1. 4、BOM编程/正则表达式

    1.    BOM编程 1.1. BOM编程基础 全称 Browser Object Model,浏览器对象模型. JavaScript是由浏览器中内置的javascript脚本解释器程序来执行jav ...

  2. python:配置文件configparser

    #-*- coding:utf8 -*- # Auth:fulimei import configparser #第一个标签 conf=configparser.ConfigParser() conf ...

  3. 过滤器(Filter)案例:检测用户是否登陆的过滤器

    *****检测用户是否登陆的过滤器:不需要用户跳转到每个页面都需要登陆,访问一群页面时,只在某个页面上登陆一次,就可以访问其他页面: 1.自定义抽象的 HttpFilter类, 实现自 Filter ...

  4. Poj(1511),SPFA

    题目链接:http://poj.org/problem?id=1511 嗯,最后一次写SPFA了,以后就套模板了. 题意:给出n个点和n条有向边,求所有点到源点1的来回最短路之和(保证每个点都可以往返 ...

  5. 更新yum源

    见地址: http://www.cnblogs.com/lightnear/archive/2012/10/03/2710952.html 163的不好用,执行失败,用alibaba的没有问题,如下: ...

  6. Github for Windows安装

    下载软件:https://desktop.github.com/ 安装之前要求系统先要有安装.net framework 4.5,不然软件安装的时候会自动上网下载安装,这软件下载起来非常慢. 第一次操 ...

  7. 最小化安装centos的init初始化脚本

    #!/bin/bash #this script is appropriate .x(这脚本适合最小化安装6.x版本的系统) #you have already install the os read ...

  8. shell中sed用法

    简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...

  9. ldataset 与 list 的使用

    [WebMethod(Description = @"根据时间查询会议项目[时间格式为:2014-01-01] DateTime StartTime , DateTime Endtime & ...

  10. Arduino中的setup()和loop()函数

    今天看arduino的源代码,对于arduino中的setup和loop有了新的理解,可能你以前对于这俩个函数就是知道arduino是初始化,而loop是死循环,但是托若你看了Arduino的主函数你 ...