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 ...
随机推荐
- android 6.0权限处理
在模拟器测试好的程序,运行在mate8上面一直崩,经多方查探才找到以下博文,方法还没掌握,但也算是找到原因了: http://***/article/android-6-0-runtime-permi ...
- ajax 无刷新分页
//ajax 无刷新分页1.前台要做的 滑动时 当前page+1,通过page ajax请求后台接口获取数据将数据进行拼装;2.后台要做的 做分页接口返回json数据前台判断触发请求条件: var p ...
- Android本机号码及Sim卡状态的获取
SIM卡存储的数据可分为四类:第一类是固定存放的数据.这类数据在移动电话机被出售之前由SIM卡中心写入,包括国际移动用户识别号(IMSI).鉴权密钥(KI).鉴权和加密算法等等.第二类是暂时存放的有关 ...
- [团队项目] Scrum 项目 2.0 产品BACKLOG
Scrum 项目 2.0 阅读教材第8章,8.1~8.3节 P157~168,了解获取用户需求的办法,每个组可以选择一二加以应用. 8.4节P168-171 查阅NABCDA模型的具体说明. 2.SC ...
- c#作业
string a = this.textBox1.Text; // string [] b=a.Split("\r\n".ToCharArray(),StringSplitOpti ...
- LoadRunner使用之变量关联
性能测试LR小结之参数关联(LoadRunner11.0) 关联对于LR是经常需要用到的,本章使用简单登录来介绍关联功能. 1. Q:何为关联? 所谓的关联就是把脚本中某些写死的代码(ha ...
- Radar之字节流加载图片
获取GUITexture GameObject _obj = GameObject.Find("Tex1"); GUITexture _tex = _obj.GetComponen ...
- GCD之dispatch queue深入浅出
GCD之dispatch queue深入浅出 http://blog.csdn.net/samuelltk/article/details/9452203
- java简单的页面制作
package 界面; import java.awt.*; import javax.swing.JFrame; import javax.swing.*; //import javax.swing ...
- 【leetcode❤python】 8. String to Integer (atoi)
#-*- coding: UTF-8 -*-#需要考虑多种情况#以下几种是可以返回的数值#1.以0开头的字符串,如01201215#2.以正负号开头的字符串,如'+121215':'-1215489' ...