In Geometry, the problem of track is very interesting. Because in some cases, the track of point may be beautiful curve. For example, in polar Coordinate system, ρ=cos3θρ=cos3θ is like rose, ρ=1−sinθρ=1−sinθ is a Cardioid, and so on. Today, there is a simple problem about it which you need to solve.
Give you a triangle ΔABCΔABC and AB = AC. M is the midpoint of BC. Point P is in ΔABCΔABC and makes min{∠MPB+∠APC,∠MPC+∠APB}min{∠MPB+∠APC,∠MPC+∠APB} maximum. The track of P is ΓΓ. Would you mind calculating the length of ΓΓ?
Given the coordinate of A, B, C, please output the length of ΓΓ.
Input
There are T (1≤T≤1041≤T≤104) test cases. For each case, one line includes six integers the coordinate of A, B, C in order. It is guaranteed that AB = AC and three points are not collinear. All coordinates do not exceed 104104 by absolute value.
Output
For each case, first please output "Case #k: ", k is the number of test case. See sample output for more detail. Then, please output the length of ΓΓ with exactly 4 digits after the decimal point.
Sample Input
1 0 1 -1 0 1 0
Sample Output
Case #1: 3.2214
题解:等腰三角形发现在高上满足,在b,c满足 所以猜测在b,c形成的弧满足,有相关证明,这里就不详细说了
详见代码
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
int main()
{
int T;
int nn=1;
scanf("%d",&T);
while(T--)
{
double ax,ay,bx,by,cx,cy;
scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&cx,&cy);
double a=sqrt((bx-cx)*(bx-cx)+(by-cy)*(by-cy));
double b=sqrt((ax-cx)*(ax-cx)+(ay-cy)*(ay-cy));
double c=sqrt((bx-ax)*(bx-ax)+(by-ay)*(by-ay));
double A=acos((b*b+c*c-a*a)/2/b/c); // 求A的角度
double O=PI-A;// 半径与AB AC相切 所以O=PI-A
double o=O/2;
double r=a/2/sqrt(1-cos(o)*cos(o));
printf("Case #%d: %.4lf\n",nn++,c*cos(A/2)+O*r);
}
return 0;
}