hdu5476 Explore Track of Point 2015上海网络赛

题目大意:一道几何题,题意是这样的,如图所示。有一个等腰三角形ABC,底边是BC,M是BC中点,在三角形内有一个点P,现在求P的轨迹,使得角BPM+角APC=角APB+角CPM=180度。ABC三个点的坐标已知。

hdu5476 Explore Track of Point 2015上海网络赛_第1张图片hdu5476 Explore Track of Point 2015上海网络赛_第2张图片

解题思路:这个题显而易见的能发现,AM三线合一,肯定是P的轨迹,因为角两两相等。除此之外,在比赛的时候,给的样例告诉我们,P的轨迹肯定不止这一条线,然后我就找从B、C出发的角平分线、高……发现都不太对,P的轨迹极有可能是一条弧线,后来我就用极限的思想,找P在哪一点符合题意。

想象当P无限接近于B的时候,若想满足题意,则P必须无限靠近AB,此时角APB=180,角MPC=0,这很明显,P的弧形轨迹会与AB相切,同理,也与AC相切。我尝试着找到一个与AB,AC相切的圆,计算出弧长BC,加上AM的长度后发现正好跟样例的答案吻合,于是我就假设这条弧线是圆弧并且与AB、AC相切,代码敲出来,竟然1A了。。。人品也是不错滴

(没有严格的证明,比赛的时候没想那么多,很多都是猜的,下意识的东西,这道题肯定是有人能证明出来的)



Explore Track of Point

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 301    Accepted Submission(s): 124


Problem Description
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,  ρ=1sinθ  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 ( 1T104 ) 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
 

Source
2015 ACM/ICPC Asia Regional Shanghai Online
 



#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int INF=0x7fffffff;
const int MAX_N=10000;
#define PI acos(-1)

int T;
double a1,b1,c1,a2,b2,c2,m1,m2;

double dis(double p1,double p2,double l1,double l2){
    return sqrt((p1-l1)*(p1-l1)+(p2-l2)*(p2-l2));
}

int main(){
    cin>>T;
    int t=T;
    while(T--){
        scanf("%lf%lf%lf%lf%lf%lf",&a1,&a2,&b1,&b2,&c1,&c2);
        m1=(b1+c1)/2;
        m2=(b2+c2)/2;

        double ab=dis(a1,a2,b1,b2);
        double bm=dis(b1,b2,m1,m2);
        double sina=bm/ab;
        double a=asin(sina);
        double r=ab*tan(a);
        double ans=(PI-2*a)*r;
        ans+=dis(m1,m2,a1,a2);
        printf("Case #%d: %.4lf\n",t-T,ans);
    }

    return 0;
}



你可能感兴趣的:(hdu5476 Explore Track of Point 2015上海网络赛)