UVA 12165 Triangle Hazard

https://cn.vjudge.net/problem/UVA-12165

题目

 

给出D、E、F分BC,CA,AB的比$m_1:m_2$,$m_3:m_4$,$m_5:m_6$和PQR三点的坐标,求ABC三点的坐标

题解

利用梅涅劳斯定理,找出直线和三边的交点,然后每个边按顺序乘下去

可以写出三个方程

\[\frac{AR}{RP}\cdot\boxed{\frac{PQ}{QB}}\cdot\frac{BF}{FA}=1\]

\[\frac{BP}{PQ}\cdot\boxed{\frac{QR}{RC}}\cdot\frac{CD}{DB}=1\]

\[\frac{CQ}{QR}\cdot\boxed{\frac{RP}{PA}}\cdot\frac{AE}{EC}=1\]

然后得到

\[\frac{AR}{RP}\cdot\frac{PQ}{PQ+BP}=\frac{m5}{m6}=k_1\]

\[\frac{BP}{PQ}\cdot\frac{QR}{QR+RC}=\frac{m1}{m2}=k_2\]

\[\frac{CQ}{QR}\cdot\frac{RP}{RP+RA}=\frac{m3}{m4}=k_3\]

 

 最后解

\[x_1=k_1(1+x_2)\]

\[x_2=k_2(1+x_3)\]

\[x_3=k_3(1+x_4)\]

然后点加向量就可以得出三点坐标

AC代码

#include<cstdio>
#include<cctype>
#include<cmath>
#define REP(r,x,y) for(register int r=(x); r<(y);r++)
#ifdef sahdsg
#define DBG(...) printf(__VA_ARGS__)
#else
#define DBG(...) (void)0
#endif
using namespace std;

int _s; char _c;
template <class T>
inline void read(T&x) {
	x=0;
	do _c=getchar(); while(!isdigit(_c) && _c!='-');
	_s=1;
	if(_c=='-') _s=-1, _c=getchar();
	while(isdigit(_c)) { x=x*10+_c-'0'; _c=getchar();} x*=_s;
}
template<class T, class...A> inline void read(T &x, A&...a){read(x); read(a...);}

#define D point
#define CD const D
struct point {
	double x,y;
	void read() {scanf("%lf%lf",&x,&y);}
	void prn() {printf("%.8lf %.8lf",x,y);}
	};
	D operator+(CD&l, CD&r) {return (D){l.x+r.x,l.y+r.y};}
	D operator-(CD&l, CD&r) {return (D){l.x-r.x,l.y-r.y};}
	D operator/(CD&l,double a) {return (D){l.x/a,l.y/a};}
	D operator*(CD&l,double a) {return (D){l.x*a,l.y*a};}
	D operator*(double a, CD &l) {return (D){l.x*a,l.y*a};}
	double cross(CD&l, CD&r) {return l.x*r.y-l.y*r.x;}
	D intersec(CD&a, D b, CD&c, D d) {
		b=b-a; d=d-c; D u=a-c;
		double t = cross(d, u) / cross(b,d);
		return a+b*t;
	}
#undef CD
#undef D
point P,Q,R,A,B,C;
#define x1 nvdsaokvl
#define x2 nvkjdavnf
#define x3 vmasdvddz
int m1,m2,m3,m4,m5,m6;
double k1,k2,k3,x1,x2,x3;
int main() {
	int N; read(N);
	while(0<N--) {
		P.read(); Q.read(); R.read();
		read(m1,m2,m3,m4,m5,m6);
		k1=(double)m5/m6, k2=(double)m1/m2, k3=(double)m3/m4;
		double t=1-k1*k2*k3;
		x1=(k1+k1*k2*k3+k1*k2)/t;
		x2=(k2+k1*k2*k3+k2*k3)/t;
		x3=(k3+k1*k2*k3+k1*k3)/t;
		DBG("%lf %lf %lf\n", x1,x2,x3);
		A=x1*(R-P)+R;
		B=x2*(P-Q)+P;
		C=x3*(Q-R)+Q;
		A.prn();putchar(' ');
		B.prn();putchar(' ');
		C.prn();putchar('\n');
	}
	return 0;
}

 

转载于:https://www.cnblogs.com/sahdsg/p/11470498.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值