Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5515
Description
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 ⋅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 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 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
1 10 13
100 10 13
Sample Output
Case #1: No
Case #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); } }