HDU 5515 Game of Flying Circus 二分

Game of Flying Circus

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5515

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<t≤1000), followed by t lines.
Each line contains three double T, V1 and V2 (0≤V1≤V2≤2000,0≤T≤2000) with no more than two decimal places, stands for one case.

Output

If there exist any strategy for Asuka to win the match, output ``Yes", otherwise, output ``No".

Sample Input

2
1 10 13
100 10 13

Sample Output

Case #1: NoCase #2: Yes

HINT

题意

题解:

http://blog.csdn.net/snowy_smile/article/details/49535301

这个文章讲的非常完美!

代码

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main()
{
    int t;scanf("%d",&t);
    for(int cas=1;cas<=t;cas++)
    {
        double T,v1,v2;
        cin>>T>>v1>>v2;
        if(v1==v2)//第一段相遇
        {
            printf("Case #%d: Yes\n",cas);
            continue;
        }
        if(300.0 * sqrt(2) / v1 < 600.0 / v2)// 第二段相遇
        {

            double l = 0,r = 300;
            for(int i=0;i<100;i++)
            {
                double mid = (l+r)/2.0;
                double len = mid * mid + 300 * 300;
                len = sqrt(len);
                double t1 = len / v1;
                double t2 = 300 / v2 + mid / v2;
                if(t1 > t2)l = mid;
                else r = mid;
            }
            double t1,t2;
            t1 = sqrt(l*l+300*300)/v1+l/v1+2*300/v1;
            t2 = T + 3*300 / v2;
            if(t1<=t2)printf("Case #%d: Yes\n",cas);
            else printf("Case #%d: No\n",cas);
        }
        else if(300.0 / v1 < 900.0 / v2)
        {
            double l = 0,r = 300;
            for(int i=0;i<100;i++)
            {
                double mid = (l+r)/2.0;
                double len = mid * mid + 300 * 300;
                len = sqrt(len);
                double t1 = len / v1;
                double t2 = (900 - mid) / v2;
                if(t1 > t2)r = mid;
                else l = mid;
            }
            double t1,t2;
            t1 = sqrt(300*300+l*l)/v1+sqrt(300*300+(300-l)*(300-l))/v1+3*300/v1;
            t2 = T + 300*4/v2;
            if(t1<=t2)printf("Case #%d: Yes\n",cas);
            else printf("Case #%d: No\n",cas);
        }
        else printf("Case #%d: No\n",cas);
    }
}
时间: 2024-10-24 09:33:27

HDU 5515 Game of Flying Circus 二分的相关文章

HDU 1150:Machine Schedule(二分匹配,匈牙利算法)

Machine Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5371    Accepted Submission(s): 2658 Problem Description As we all know, machine scheduling is a very classical problem in compu

HDU 4004 The Frog&#39;s Games 二分 贪心

戳这里:HDU 4004 //思路:二分经典入门题...贪心判方案是否可行 1 #include "bits/stdc++.h" 2 using namespace std; 3 int L, n, m; 4 int pos[500010], dis[500010]; 5 6 bool Cant(int Dis_Jump) 7 { 8 int i, Dis_Sum = 0, Count = 0; 9 for(i = 1; i <= n + 1; ++i) { 10 if(dis[

hdu 4430 Yukari&#39;s Birthday 枚举+二分

注意会超long long 开i次根号方法,te=(ll)pow(n,1.0/i); Yukari's Birthday Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3262    Accepted Submission(s): 695 Problem Description Today is Yukari's n-th birt

HDU 4004 The Frog&#39;s Games 二分

1.题意:一条河长为L,河上有N块石头,一只青蛙可以利用这些石头从河的一端跳到对岸,可以跳不超过M次,求各种跳法中,找到最小化的最大步长.输入第一行依次给出L.N.M,第二行依次给出N块石头距离起点的距离. 2.分析:这类最小化最大值的问题用二分来求解最高效.先预先处理,连同起点,终点,共N+2个点排序,两两相减得到N+1段距离C[i],即跨一步的最小距离.二分维护mid值,上界为河长L,下界为两两距离之中的最大值maxC[i](反证易知),以mid值分割C[i]数组,分割的段数<=M则mid偏

HDU - 1845 Jimmy’s Assignment (二分匹配)

Description Jimmy is studying Advanced Graph Algorithms at his university. His most recent assignment is to find a maximum matching in a special kind of graph. This graph is undirected, has N vertices and each vertex has degree 3. Furthermore, the gr

hdu 4938 Seeing People 排序+二分查找

Seeing People Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 241    Accepted Submission(s): 61 Problem Description There are two kinds of people. If person i is the first kind of people, it

hdu 3641 Treasure Hunting 强大的二分

1 /** 2 大意:给定一组ai,bi . m = a1^b1 *a2^b2 * a3^ b3 * a4^b4*...*ai^bi 3 求最小的x!%m =0 4 思路: 将ai 质因子分解,若是x!%m=0 那么x! 质因子分解之后 质因子的个数一定大于等于m的个数.二分求解可得 5 注意: 二分时,需要将,上下限 设定好,low =0: high = 1ll<<60; 6 **/ 7 8 #include <iostream> 9 #include <cstring&g

HDU 1498 50 years, 50 colors(二分最大匹配之最小点覆盖)

题目地址:HDU 1498 晕啊...三个人同时做的这个题,结果全都理解错意思了..而且每个人理解错的地方还都不一样..但是样例还都能过,...简直炫酷... 题意:n*n的矩阵放置不同的颜色(不同的数字代表不同的颜色),你有k次选择,每一次只能选择某一行或某一列,可以消除该行(列)的所有颜色,问有哪几种颜色,无论怎样经过k次选择后依然无法完全抹去. 这个题的思路就是分别求出每种颜色的最少操作次数.然后只要大于k次的就是不符合要求的.然后输出就行了. #include <iostream> #

hdu 4430 Yukari&#39;s Birthday(二分)

Yukari's Birthday Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2703    Accepted Submission(s): 556 Problem Description Today is Yukari's n-th birthday. Ran and Chen hold a celebration party