Give a graph, tell the coordinates of the three points of R, p, q, and find the coordinates of the three points of A, B, and C.
My practices:
Based on the menielos theorem, we can list three systems of binary equations, obtain the length of Pb, QC, and Ra, and then use the point displacement to obtain the coordinates of A, B, and C.
My code:
#include<iostream>#include<map>#include<string>#include<cstring>#include<cstdio>#include<cstdlib>#include<cmath>#include<queue>#include<vector>#include<algorithm>using namespace std;struct dot { double x,y; dot(){} dot(double a,double b){x=a,y=b;} friend dot operator -(dot a,dot b){return dot(a.x-b.x,a.y-b.y);} friend dot operator +(dot a,dot b){return dot(a.x+b.x,a.y+b.y);} friend dot operator *(dot a,double b){return dot(a.x*b,a.y*b);} friend double operator /(dot a,dot b){return a.x*b.x+a.y*b.y;} friend double operator *(dot a,dot b){return a.x*b.y-a.y*b.x;}};struct fun { double a,b,c; fun(){} fun(double x,double y,double z) { a=x; b=y; c=z; } }; dot sf(fun a,fun b) { double c,d,e; c=dot(a.a,b.a)*dot(a.b,b.b); d=dot(a.c,b.c)*dot(a.b,b.b); e=dot(a.a,b.a)*dot(a.c,b.c); return dot(d/c,e/c); }double dis(dot a,dot b){return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));}dot cd(dot a){double t=dis(a,dot(0,0));return dot(a.x/t,a.y/t);}int main(){int N,i;double m[10],pr,pq,rq;dot a,b,c,d[10];cin>>N;while(N--){for(i=0;i<3;i++)cin>>d[i].x>>d[i].y;for(i=1;i<7;i++)cin>>m[i];pr=dis(d[0],d[2]);pq=dis(d[0],d[1]);rq=dis(d[1],d[2]);a=sf(fun((m[1]+m[2])*m[4],-m[1]*m[3],m[1]*m[3]*pr),fun(m[5]*(m[1]+m[2]),-m[2]*m[6],-m[5]*(m[1]+m[2])*pr));a=cd(d[2]-d[0])*a.y+d[2];b=sf(fun(m[2]*m[4],-m[1]*(m[3]+m[4]),m[1]*(m[3]+m[4])*pq),fun(m[3]*m[5],-m[6]*(m[3]+m[4]),-m[3]*m[5]*pq));b=cd(d[0]-d[1])*b.x+d[0];c=sf(fun(m[3]*(m[5]+m[6]),-m[4]*m[6],-m[3]*(m[5]+m[6])*rq),fun(m[2]*(m[5]+m[6]),-m[1]*m[5],m[1]*m[5]*rq));c=cd(d[1]-d[2])*c.y+d[1];printf("%.8lf %.8lf %.8lf %.8lf %.8lf %.8lf\n",a.x,a.y,b.x,b.y,c.x,c.y);}}
Original question:
Time Limit: 3.000 seconds
In the picture below you can see a triangleABC. PointD,EAndFDivides the sidesBC,CAAndABIntoM1: m2,M3: M4AndM5: M6Ratios respectively.A, D;B, EAndC, FAre connected.AdAndBeIntersectsP,BeAndCfIntersectsQAndCfAndAdIntersectsR.
So now a new trianglePqrIs formed. Given triangleABCIt is very easy to find trianglePqr, But given trianglePqrIt is not straight forward to findABC. Your task is now to do that.
Input
First line of the input file contains an integerN (0 <n <25001)Which denotes How many sets of inputs are there. inputfor each set contains six floating-point numberPx, Py, QX, QY, RX, Ry.(0 ≤ PX, Py, QX, QY, RX, Ry ≤ 10000)In one line and six positive integersM1, M2, M3, M4, M5, M6 (M1 <M2, M3 <M4AndM5 <m6)In another line. These six numbers denote that the coordinate of pointsP, qAndRAre(PX, Py), (QX, QY)And(RX, ry)Respectively.P, qAndRWill never be collinear and will be distinct and therewill always be a triangleABCFor the given input trianglePqr. Also note thatP,QAndRWill be given in counterclockwise order in the input.
Output
For each line of input produce one line of output. thisline contains six floating-point numbers. These six integers denote the coordinatesofA, BAndC. That is the first two integers denote thecoordinateA, The third and fourth integers denote the coordinateBAnd th and sixth integers denotes the coordinateC.A, BAndCWill appear counter clockwise order. All the output numbers shouldhave eight digits after the decimal point.
Sample Input
3 4467.61586728 8492.59551366 7060.96479020 6775.46633005 6725.89311907 9028.87449315 11 56 38 97 49 60 5779.32806104 1918.19337634 7490.69623286 4845.34535926 6419.53729066 4864.56878239 18 80 56 87 58 59 8991.93033007 6724.32910758 7219.48100000 7527.95330769 8549.92222645 3068.19948096 13 86 11 44 20 35 |
Output for sample input
9231.81800000 9623.96300000 3537.20000000 9108.65000000 7337.89000000 4913.10199999 7424.76700001 9490.84399999 4757.24799999 170.01100001 9262.77299999 4813.54299999 8242.99300000 529.39300000 9373.35300000 6551.39300000 6655.90700000 9417.10200000 |
Problemsetter: Shahriar Manzoor, special thanks: rujia Liu
UV live-4413-triangle hazard