zoj 1821 || poj 1673 Exocenter of a Triangle

211 篇文章 0 订阅
134 篇文章 1 订阅

求垂心。分类上直接说了,无语。如果我看的话应该第一反应是模拟一遍吧。。

pojdiscuss上有证明。

ZOJ死活不过,后来看大黄的题解,可能会输出-0.0000,这个。。。无语shi。。

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <string>
#include <algorithm>
#define MID(x,y) ( ( x + y ) >> 1 )
#define L(x) ( x << 1 )
#define R(x) ( x << 1 | 1 )
#define BUG puts("here!!!")
#define STOP system("pause")

using namespace std;

const double eps = 1e-6;
struct point {
	double x,y;
	void get()
	{
		scanf("%lf%lf", &x, &y);
	}
};

point a,b,c;

point l2l_inst_p(point u1,point u2,point v1,point v2)
{
	point ans = u1;
	double t = ((u1.x - v1.x)*(v1.y - v2.y) - (u1.y - v1.y)*(v1.x - v2.x))/
				((u1.x - u2.x)*(v1.y - v2.y) - (u1.y - u2.y)*(v1.x - v2.x));
	ans.x += (u2.x - u1.x)*t;
	ans.y += (u2.y - u1.y)*t;
	return ans;
}
point perpencenter(point a,point b,point c)
{
	point ua,ub,va,vb;
	ua = c;
	ub.x = ua.x - a.y + b.y;
	ub.y = ua.y + a.x - b.x;
	va = b;
	vb.x = va.x - a.y + c.y;
	vb.y = va.y + a.x - c.x;
	return l2l_inst_p(ua,ub,va,vb);
}

int main()
{
	int ncases;
	
	scanf("%d", &ncases);
	
	while( ncases-- )
	{
		a.get(); b.get(); c.get();
		point ans = perpencenter(a, b, c);
		if( fabs(ans.x) < eps ) ans.x = 0;
		if( fabs(ans.y) < eps ) ans.y = 0;
		printf("%.4lf %.4lf\n", ans.x, ans.y);
	}

return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值