HDU 5476 Explore Track of Point (2015年上海赛区网络赛I题)

来源:互联网 发布:淘宝店刷销量方法 编辑:程序博客网 时间:2024/05/16 14:11

1.题目描述:点击打开链接

2.解题思路:本题需要事先求出点P的轨迹形状,容易发现,题目要求找的是2角相加恰好是180度时候点的轨迹。比赛时候猜出来样例是由sqrt(2)*PI/2+1得到的,然而没有想到这个圆长什么样子==,差点就猜到圆的半径是sqrt(2),圆心角是90度了。那只有一种情况就是这个圆和等腰三角形的两条边是旁切的。至于证明,过程比较复杂,因此在此略去。大概如下:

3.代码:

#include<iostream>#include<algorithm>#include<cassert>#include<string>#include<sstream>#include<set>#include<bitset>#include<vector>#include<stack>#include<map>#include<queue>#include<deque>#include<cstdlib>#include<cstdio>#include<cstring>#include<cmath>#include<ctime>#include<cctype>#include<list>#include<complex>#include<functional>#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;#define me(s)  memset(s,0,sizeof(s))#define rep(i,n) for(int i=0;i<(n);i++)typedef long long ll;typedef unsigned int uint;typedef unsigned long long ull;typedef pair <int,int> P;#define me(s)  memset(s,0,sizeof(s))#define rep(i,n) for(int i=0;i<(n);i++)typedef long long ll;typedef unsigned int uint;typedef unsigned long long ull;typedef pair<int,int> P;struct Point{    double x,y;    Point(){}    Point(double x,double y):x(x),y(y){}    void read()    {        scanf("%lf%lf",&x,&y);    }};typedef Point Vector;Vector operator+(Vector a,Vector b){return Vector(a.x+b.x,a.y+b.y);}Vector operator-(Vector a,Vector b){return Vector(a.x-b.x,a.y-b.y);}Vector operator*(Vector a,double p){return Vector(a.x*p,a.y*p);}double Dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}double Cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}double Length(Vector a){return sqrt(Dot(a,a));}Point a,b,c;int main(){    int T;    int rnd=0;    scanf("%d",&T);    while(T--)    {        a.read();        b.read();        c.read();        Vector v1=c-b;        Vector v2=a-b;        double h=fabs(Cross(v1,v2))/Length(v1);        double L1=Length(v2),L2=Length(v1);        double R=L1*L2/(2*h);        double e=acos(1-(L2*L2/(2*R*R)));        double ans=e*R+h;        printf("Case #%d: %.4lf\n",++rnd,ans);    }}

0 0
原创粉丝点击