zoj 1821 || poj 1673 Exocenter of a Triangle

前端之家收集整理的这篇文章主要介绍了zoj 1821 || poj 1673 Exocenter of a Triangle前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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,vb);
}

int main()
{
	int ncases;
	
	scanf("%d",&ncases);
	
	while( ncases-- )
	{
		a.get(); b.get(); c.get();
		point ans = perpencenter(a,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;
}
原文链接:https://www.f2er.com/vb/260977.html

猜你在找的VB相关文章