UVA LIVE-4413 - Triangle Hazard

给个图,告诉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 and
CF intersects at Q and CF and
AD
intersects at R.

So now a new triangle PQR is formed. Given triangleABC it is very easy to find triangle
PQR, but given triangle PQRit is not straight forward to find
ABC. 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 number
Px, Py,Qx, Qy, Rx, Ry.
(0 ≤ Px,Py, Qx, Qy, Rx, Ry ≤10000) in one line and six positive integers
m1, m2,m3, m4, m5, m6 (m1<m2,m3<m4
and m5<m6)in another line. These six numbers denote that the coordinate of points
P, Qand R are (Px, Py), (Qx, Qy)and
(Rx,Ry) respectively.P, Q and
R will never be collinear and will be distinct and therewill always be a triangle
ABC for the given input triangle PQR.Also note that
P, 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 coordinatesof
A, B and C. That is the first two integers denote thecoordinate of
A, the third and fourth integers denote the coordinate of
B
and 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

时间: 2024-11-07 18:08:15

UVA LIVE-4413 - Triangle Hazard的相关文章

uva 11186 - Circum Triangle(几何)

题目链接:uva 11186 - Circum Triangle 枚举两点,计算该两点与圆心构成的三角形对ans的贡献值. #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int maxn = 505; const double pi = 4 * atan(1); double A[maxn]; doub

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

【UVA】11437 Triangle Fun(简单几何)

先求出在A,B,C上的三等分点在,这里使用向量运算进行加减就行了. 之后通过求出的三等分点 和 顶点的连线,求出3个交点. 最后用求出的三个交点算出面积. 注意:由于可能是钝角三角形,需要求其绝对值. 14116428 11437 Triangle Fun Accepted C++ 0.015 2014-08-30 03:27:36 #include <iostream> #include <cstdlib> #include <cstdio> #include <

【UVA 11401】Triangle Counting

题 题意 求1到n长度的n根棍子(3≤n≤1000000)能组成多少不同三角形. 分析 我看大家的递推公式都是 a[i]=a[i-1]+ ((i-1)*(i-2)/2-(i-1)/2)/2; 因为以最大长度i 为最大边的三角形有 第二边为i-1.i-2....2 分别有 i-2个.i-3.... .1个,总共就有(i-1)*(i-2)/2个. 2 到 i-1 做第二边时,有(i-1)/2条边算到了两边相等,也就是要减去 (i-1)/2,因为第二边的在第三边出现了,所以算了两次,再除以2. 我的递

UVA 11186 - Circum Triangle(计算几何+容斥)

这题用n^2的算法能过,先任意枚举两点,和圆心组成的三角形求面积,这个面积可能会被加(n - 2)次,但是要注意,如果有3点是在同一侧,那么要减去,于是在枚举一遍,每次枚举一个点,然后枚举和这个点度数相差180以内的点,求面积,这个面积要减去2 * (j - i + 1)次 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespac

UVA - 11186 Circum Triangle (几何)

题意:有N个点,分布于一个圆心在原点的圆的边缘上,问所形成的所有三角形面积之和. 分析: 1.sin的内部实现是泰勒展开式,复杂度较高,所以需预处理. 2.求出每两点的距离以及该边所在弧所对应的圆周角.一条弧所对圆周角等于它所对圆心角的一半. 3.S = 1/2*absinC求三角形面积即可. #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<c

计算几何题目分类

转载 一.基础题目 1.1 有固定算法的题目 A, 最近点对问题最近点对问题的算法基于扫描线算法.ZOJ 2107    Quoit Design    典型最近点对问题POJ    3714    Raid    变种最近点对问题 B,最小包围圆最小包围圆的算法是一种增量算法,期望是O(n).ZOJ    1450    Minimal Circle  HDU    3007    Buried memory C,旋转卡壳POJ 3608    Bridge Across Islands   

几何基础专题

UVA 11437 Triangle Fun UVA 11800 Determine the Shape 四边形判定 UVA 11646 Athletics Track UVA 11817 Tunnelling the Earth 球面距离 UVA 1473 Dome of Circus UVA 11524 InCircle UVA 11731 Ex-circles 旁切圆 UVA 12300 Smallest Regular Polygon UVA 10566 Crossed Ladders

UVA - 11437 - Triangle Fun (计算几何~)

UVA - 11437 Triangle Fun Time Limit: 1000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Submit Status Description Problem A Triangle Fun Input: Standard Input Output: Standard Output In the picture below you can see a triangle ABC. Point D, E