链接:http://acm.hdu.edu.cn/showproblem.php?pid=5476
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θ is like rose, ρ=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 and AB = AC. M is the midpoint of BC. Point P is in ΔABC and makes 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≤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 104 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
哇!和队友凑数字凑了半天最后凑了出来,但是最后时间不够没有ac,难受。
所求值为:中垂线+以两条垂线的交点为圆心垂线为半径画圆在三角形中的那断弧长
求证的话别的博客有,诶我也不会。
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
int main()
{
int T;
cin>>T;
int aa=1;
while(T--)
{
double x,y,x1,y1,x2,y2;
scanf("%lf%lf%lf%lf%lf%lf",&x,&y,&x1,&y1,&x2,&y2);
double L=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double R=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
double s=sqrt((x-(x1+x2)/2)*(x-(x1+x2)/2)+(y-(y1+y2)/2)*(y-(y1+y2)/2));
double ang=acos(L/(2*R));
double r=L/sin(ang)/2;
double num=r*ang*2;
printf("Case #%d: %.4lf\n",aa++,s+num);
}
return 0;
}