https://cn.vjudge.net/problem/UVA-12165
topic
Given D, E, F points BC, CA, AB than $ m_1: m_2 $, $ m_3: m_4 $, $ m_5: m_6 $ PQR and three coordinates, find the coordinates of three points ABC
answer
The use of Menelaus' theorem to find the intersection of the line and three sides, and then take down each side in order
You can write three equations
\[\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\]
Then get
\[\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\]
Final solution
\[x_1=k_1(1+x_2)\]
\[x_2=k_2(1+x_3)\]
\[x_3=k_3(1+x_4)\]
Then add vectors can draw three coordinates
AC Code
#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; }