UVA LIVE-4413 - Triangle Hazard
来源:互联网 发布:软件系统结构图 visio 编辑:程序博客网 时间:2024/06/05 17:18
给个图,告诉R,P,Q三点的坐标,求出A,B,C三点的坐标
我的做法:
根据梅涅劳斯定理列出三个二元一次方程组,求出pb,qc,ra的长度,然后用点位移求出A,B,C三点的坐标即可
我的代码:
#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);}}
原题:
Time limit: 3.000 seconds
In the picture below you can see a triangle ABC.Point D, E and F divides the sides BC,CAand AB into m1:m2,m3:m4and m5:m6 ratios respectively.A, D; B,E and C, F are connected.AD and BE intersects at P,BE andCF intersects at Q and CF and ADintersects at R.
So now a new triangle PQR is formed. Given triangleABC it is very easy to find trianglePQR, but given triangle PQRit is not straight forward to findABC. Your task is now to do that.
Input
First line of the input file contains an integer N (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<m4and m5<m6)in another line. These six numbers denote that the coordinate of pointsP, Qand R are (Px, Py), (Qx, Qy)and(Rx,Ry) respectively.P, Q andR will never be collinear and will be distinct and therewill always be a triangleABC for the given input triangle PQR.Also note thatP, Q and R will 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, B and C. That is the first two integers denote thecoordinate ofA, the third and fourth integers denote the coordinate of Band fifth and sixth integers denotes the coordinate of C.A, Band C will 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
- UVA LIVE-4413 - Triangle Hazard
- uva 12165 - Triangle Hazard
- Triangle Hazard - UVa 12165 几何
- uva 12165 - Triangle Hazard(几何)
- LA 4413 Triangle Hazard 梅涅劳斯定理的应用
- Uva-Live Archive3902-Network
- Uva-Live 3905-Meteor
- UVA live 2678 - Subsequence
- UVA Live 6068
- uva live 6479
- uva live 6481
- uva live 6183 Stylish
- uva live 4725题解
- uva live 4728
- UVa Live 7278
- UVa 488 Triangle Wave
- Uva 488 Triangle Wave
- UVa Triangle Wave
- 黑马程序员--Java高新技术(2)
- OpenStack Neutron在Juno版本的新特性
- linux下搭建SVN遇到authentication failed问题的解决方法
- SQLServer 2008数据库查看死锁、堵塞的SQL语句
- mysqldump: Got error: 1016: Can't open file: '***.frm' (errno: 24) when usin
- UVA LIVE-4413 - Triangle Hazard
- GitHub详细教程
- Cocos2d-x绘图API:DrawingPrimitives和DrawNode
- 递归算法详细分析
- LoadRunner场景参数文件部分参数说明
- 黑马程序员 【】java学习之路——代理小结
- Android AIDL使用详解
- mongoDB之监控工具mongotop
- mongoDB之监控工具mongostat