Problem E
In-Circle
Input: Standard Input
Output: Standard Output
In-circle of a triangle is the circle that touches all the three sides of the triangle internally. The center of the in-circle of a triangle happens to be the common intersection point of the three bisectors of the internal angles. In this problem you will not be asked to find the in-circle of a triangle, but will be asked to do the opposite!!
You can see in the figure above that the in-circle of triangle ABC touches the sides AB, BC and CA at point P, Q and R respectively and P, Q and R divides AB, BC and CA in ratio m1:n1, m2:n2 and m3:n3 respectively. Given these ratios and the value of the radius of in-circle, you have to find the area of triangle ABC.
Input
First line of the input file contains an integer N (0<N<50001), which denotes how many input sets are to follow. The description of each set is given below.
Each set consists of four lines. The first line contains a floating-point number r (1<r<5000), which denotes the radius of the in-circle. Each of the next three lines contains two floating-point numbers, which denote the values of m1, n1, m2, n2, m3 and n3 (1<m1, n1, m2, n2, m3, n3<50000) respectively.
Output
For each set of input produce one line of output. This line contains a floating-point number that denotes the area of the triangle ABC. This floating-point number should contain four digits after the decimal point. Errors less than 5*10-3 will be ignored. Use double-precision floating-point number for calculation.
Sample Input Output for Sample Input
2 140.9500536497 15.3010457320 550.3704847907 464.9681681852 65.9737378230 55.0132446384 10.7791711946 208.2835101182 145.7725891419 8.8264176452 7.6610997600 436.1911036207 483.6031801012 140.2797089713 | 400156.4075 908824.1322 |
Problemsetter: Shahriar Manzoor
Special Thanks: Mohammad Mahmudur Rahman
题意:有一个三角形ABC,内部有个内切圆,有切点QRP,然后给出内切圆的半径和一些比例关系,求出三角形面积。
思路:根据比例关系我们能用余弦定理得出角度,然后就能求出边长了,最后面积等于周长*0.5*半径。
代码:
#include<iostream>
#include<cstdio>
#include<string.h>
#include<math.h>
#include<cstring>
#include<algorithm>
using namespace std;
#define eps 1e-9
struct Point
{
Point (double xx=0,double yy=0) : x(xx) , y(yy) { }
double x;
double y;
};
typedef Point Vector;
Vector operator+(Vector v1,Vector v2) { return Vector(v1.x+v2.x,v1.y+v2.y); }
Vector operator-(Vector v1,Vector v2) { return Vector(v1.x-v2.x,v1.y-v2.y); }
Vector operator*(Vector v, double p) { return Vector(v.x*p,v.y*p); }
Vector operator/(Vector v,double p) { return Vector(v.x/p,v.y/p); }
bool operator < (Point a,Point b) { return a.x < b.x || (a.x==b.x && a.y > b.y); }
int dcmp(double x)
{
if (fabs(x) < eps) return 0;
return x < 0 ? -1 : 1;
}
bool operator==(const Point & a,const Point & b)
{
return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;
}
double Dot(Vector A,Vector B) { return A.x*B.x+A.y*B.y; }
double Length(Vector A) { return sqrt(Dot(A,A)); }
double Angle(Vector A,Vector B) { return acos(Dot(A,B)/Length(A)/Length(B)); }
double Cross(Vector A,Vector B) { return A.x*B.y-A.y*B.x; }
double Area2(Point a,Point b,Point c) { return Cross(b-a,c-a); }
Vector Rotate(Vector A,double rad)
{
return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
Vector Normal(Vector A) { double L = Length(A); return Vector(-A.y/L,A.x/L); }
//点和直线
Point GetLineIntersection(Point P,Vector v,Point Q,Vector w)
{
Vector u = P-Q;
double t = Cross(w,u) / Cross(v,w);
return P+v*t;
}
double DistanceToLine(Point P,Point A,Point B)
{
Vector v1 = B-A , v2 = P-A;
return fabs(Cross(v1,v2))/Length(v1);
}
double DistanceToSegment(Point P,Point A,Point B)
{
if (A==B) return Length(P-A);
Vector v1 = B-A , v2 = P-A , v3 = P-B;
if (dcmp(Dot(v1,v2)) < 0) return Length(v2);
else if (dcmp(Dot(v1,v3)) > 0) return Length(v3);
else return fabs(Cross(v1,v2))/Length(v1);
}
Point GetLineProjection(Point P,Point A,Point B)
{
Vector v = B-A;
return A+v*(Dot(v,P-A)/Dot(v,v));
}
bool SegmentProperIntersection(Point a1,Point a2,Point b1,Point b2)
{
double c1 = Cross(a2-a1,b1-a1) , c2 = Cross(a2-a1,b2-a1) ,
c3 = Cross(b2-b1,a1-b1) , c4 = Cross(b2-b1,a2-b1);
return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3)*dcmp(c4)<0;
}
bool OnSegment(Point p,Point a,Point b) {
return dcmp(Cross(a-p,b-p))==0 && dcmp(Dot(a-p,b-p)) < 0;
}
//--------------------------------------------------------------------------------------------
inline double sqr(double x) { return x*x; }
int main()
{
double m1,n1,m2,n2,m3,n3,r;
int T; cin>>T;
while (T--)
{
scanf("%lf",&r);
scanf("%lf%lf%lf%lf%lf%lf",&m1,&n1,&m2,&n2,&m3,&n3);
double rad = acos(1-2*m1*n2/((n1+m1)*m2+(n1+m1)*n2));
double x = r/tan(rad*0.5);
double area = 0.5*r*(2+2*n2/m2+2*m1/n1)*x;
printf("%.4lf\n",area);
}
}