2186: Triangle Centers
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
![]() | 3s | 8192K | 67 | 38 | Standard |
(1) FA + FB + FC. F is the point X which minimizes the sum of distances from A, B, and C in XA+XB +XC.
(2) IA + IB + IC. I is the intersection of Angle Bisectors, and it is the interior point for which distances to the sidelines are equal.
(3) GA + GB + GC. G is the intersection of Medians, and it is the centroid of ABC.
(4) OA + OB + OC. O is the intersection of Perpendicular Bisectors, and it is the point for which distances to A, B, C are equal.
Input
The input consists of T test cases. The number of test cases (T ) is given in the first line of the input. Each of the next T lines contains one test case. Each case contains three integer numbers a, b, c where a is the distance between B and C, b is the distance between C and A and c is the distance between A and B. The important condition is 0 < a; b; c <= 1000, and it is guaranteed that the triangle is non-degenerate.Output
For each set of input you should output four floating-point numbers DF , DI , DG, DO, all of which have exactly three digits after the decimal point. HereDF = FA + FB + FC
DI = IA + IB + IC
DG = GA + GB + GC
DO = OA + OB + OC
Sample Input
3 3 4 5 10 10 10 4 5 8
Sample Output
6.766 6.813 6.918 7.500 17.321 17.321 17.321 17.321 9.000 9.316 9.530 14.667
Problem Source: SJTU Programming Contest 2004
#include<stdio.h>
#include<math.h>
#include<algorithm>
using std::swap;
int main()
{
int T,a,b,c;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&a,&b,&c);
if(a>b) swap(a,b);if(b>c) swap(b,c);if(a>c) swap(a,c);
double s=(a+b+c)*1.0/2;
double area=sqrt(s*(s-a)*(s-b)*(s-c));
//费马点
double l1;
double d=acos((a*a+b*b-c*c)*1.0/(2*a*b));
if(d>acos(-1)*2/3) l1=a+b;
else l1=sqrt(a*a+b*b+c*c+4*sqrt(3.0)*area)*sqrt(2)/2;
printf("%.3lf ",l1);
//2 内心,内接圆半径为2*area/(A+B+C),然后用三角公式算下就行。
double r2=2*area/(a+b+c);
double t=acos((a*a+b*b-c*c)*1.0/(2*a*b));
double l2=0;
l2+=r2/sin(t/2);
t=acos((a*a+c*c-b*b)*1.0/(2*a*c));
l2+=r2/sin(t/2);
t=acos((b*b+c*c-a*a)*1.0/(2*b*c));
l2+=r2/sin(t/2);
printf("%.3lf ",l2);
//重心
double l3=sqrt((2*a*a+2*b*b-c*c)*1.0/9)+sqrt((2*a*a+2*c*c-b*b)*1.0/9)+sqrt((2*c*c+2*b*b-a*a)*1.0/9);
printf("%.3lf ",l3);
//外心
double r4=a*b*c*1.0/(4*area);
double l4=3*r4;
printf("%.3lf/n",l4);
}
return 0;
}