【hdu5515】【2015ACM/ICPC亚洲区沈阳站】 Game of Flying Circus 题意&题解&代码(C++)

题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5515
题意:
不得不说,这题意很扯,不过还是有好心人将题意写的很清楚,我只想说阅读理解满分。
题意&题解传送门:
http://blog.csdn.net/snowy_smile/article/details/49535301
代码:

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int stest;
double T,v1,v2;
const double len=300.0;
int main()
{
    scanf("%d",&stest);
    for (int t=1;t<=stest;t++)
    {
        cin>>T>>v1>>v2;
        if (v1==v2)
        {
            printf("Case #%d: Yes\n",t);
            continue;
        }
        double gen2=sqrt(2.0);
        double len2=len*len;
        if ((len*gen2/v1)<=(len*2.0/v2))
        {
            double l=0.0;
            double r=len;
            while(r-l>0.0000001)
            {
                double mid=(l+r)/2.0;
                double s1=sqrt(mid*mid+len2);
                double s2=mid+len;
                if ((s1/v1)<=(s2/v2))
                r=mid;
                else
                l=mid;
            }
            double t1,t2;
            t1=sqrt(r*r+len2)/v1+(r+2*len)/v1;
            t2=T+(3*len)/v2;
            if (t1<=t2) printf("Case #%d: Yes\n",t);
            else printf("Case #%d: No\n",t);
        }
        else if ((len/v1)<((3*len)/v2))
        {
                        double l=0.0;
                        double r=len;
                        while(r-l>0.0000001)
                        {
                                double mid=(l+r)/2.0;
                                double s1=sqrt(mid*mid+len2);
                                double s2=3*len-mid;
                                if ((s1/v1)<=(s2/v2))
                                l=mid;
                                else
                                r=mid;
                        }
                        double t1,t2;
            double stmp=sqrt((len-r)*(len-r)+len2);
                        t1=sqrt(l*l+len2)/v1+stmp/v1+(3*len)/v1;
                        t2=T+(4*len)/v2;
                        if (t1<=t2) printf("Case #%d: Yes\n",t);
                        else printf("Case #%d: No\n",t);            
        }
        else printf("Case #%d: No\n",t);
    }
}

你可能感兴趣的:(ACM,二分,亚洲)