【HDU5515】【2015ACM/ICPC亚洲区沈阳站】 Game of Flying Circus 二分

Game of Flying Circus
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 504 Accepted Submission(s): 127

Problem Description
The discovery of anti-gravitations technology changed the world. The invention of anti-gravitation shoes (Grav-shoes) enables people to fly in the sky freely. This led to the rise of a new sky sport: “Flying Circus”.

Utilizing Grav-shoes and personal flying suits, competitors battle it out in a special field, where they compete scoring obtain m points within a certain time limit. The field is a square with edge length 300 meters. Moreover, there are four buoys floating at each corner of the square. Four buoys are numbered as 1,2,3,4 in clockwise order.

Two players start at buoy #1. When game begin, they will try to touch four floating buoys in clockwise order.
(Since buoy #1 is the start point, the first buoy they need to touch will be buoy #2, and after that, they need to touch buoy #3,#4,#1 in order) Note that they could fly freely in the field, even fly inside the square field.

Under two situations the player could score one point.

⋅1. If you touch a buoy before your opponent, you will get one point. For example if your opponent touch the buoy #2 before you after start, he will score one point. So when you touch the buoy #2, you won’t get any point. Meanwhile, you cannot touch buoy #3 or any other buoys before touching the buoy #2.

⋅2. Ignoring the buoys and relying on dogfighting to get point. If you and your opponent meet in the same position, you can try to fight with your opponent to score one point. For the proposal of game balance, two players are not allowed to fight before buoy #2 is touched by anybody.

There are three types of players.

Speeder: As a player specializing in high speed movement, he/she tries to avoid dogfighting while attempting to gain points by touching buoys.
Fighter: As a player specializing in dogfighting, he/she always tries to fight with the opponent to score points. Since a fighter is slower than a speeder, it’s difficult for him/her to score points by touching buoys when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.

There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.

Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting. Since Asuka is slower than Shion, she decides to fight with Shion for only one time during the match. It is also assumed that if Asuka and Shion touch the buoy in the same time, the point will be given to Asuka and Asuka could also fight with Shion at the buoy. We assume that in such scenario, the dogfighting must happen after the buoy is touched by Asuka or Shion.

The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?

Input
The first line contains an integer t (0

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
using namespace std;
int S;
double T,v1,v2; 

int main()
{
    scanf("%d",&S);
    for(int cas=1;cas<=S;cas++)
    {
        cin>>T>>v1>>v2;
        double t1=300/v1;
        double t2=300/v2;

        if(v1==v2) 
        {   
            printf("Case #%d: Yes\n",cas);
                    continue;
        }
        if(v1*v1*2>=v2*v2)
        {
            double lx=0,rx=300;
            for(int i=1;i<=100;i++)
            {
                double  mid=(lx+rx)/2;
                double l1=mid*mid+300*300;
                l1=sqrt(l1);
                double tt1=l1/v1;
                double l2=mid+300;
                double tt2=l2/v2;
                if(tt1>tt2) lx=mid;
                else rx=mid;
            }
            double tt1=sqrt(lx*lx+300*300)/v1+2*t1+lx/v1;
            double tt2=t2*3+T;
            if(tt1>tt2)  printf("Case #%d: No\n",cas);
            else    printf("Case #%d: Yes\n",cas);
        }
        else if(v1*3>v2)
        {
            double lx=0,rx=300;
            for(int i=1;i<=100;i++)
            {
                double  mid=(lx+rx)/2;
                double l1=mid*mid+300*300;
                l1=sqrt(l1);
                double tt1=l1/v1;
                double tt2=t2*2+(300-mid)/v2;
                if(tt1>tt2) rx=mid;
                else lx=mid;
            }
            double tt1=sqrt(lx*lx+300*300)/v1+sqrt((300-lx)*(300-lx)+300*300)/v1+3*t1;
            double tt2=t2*4+T;
            if(tt1>tt2)  printf("Case #%d: No\n",cas);
            else    printf("Case #%d: Yes\n",cas);

        }
        else
        {
            printf("Case #%d: No\n",cas);
                    continue;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值