zoukankan      html  css  js  c++  java
  • ZOJ 3235 Prototype

    Prototype

    Time Limit: 1 Second      Memory Limit: 32768 KB

    Prototype is a 3D game which allow you to control a person named Alex with much super ability to finish missions with gut along. Alex has the abilitiy to glide in the sky. What's more, he can make at most 3-level glide, which means before he lands at the ground, he has two chances to adjust and perform another glide. We assume that each time he perform a glide, his vertical speed become zero and glide forward with a new speed. And the orbit will be a parabola due to the gravity.

    To make the problem easier, we now only consider at most 2-level glide. The binomial coefficient of the mathematical equation of the fist glide will be given as -a and the second will be -b, which means the formulations are (y - y0) = -ax2 and (y - y0) = -b(x - x0)2. As the picture above, Alex perform a glide from the top of Building1, make a 1-level or a 2-level glide and lands exactly at point B. What's more, there is Building2 standing between Building1 and point B. Alex has to avoid crashing onto it.

    Input

    There are no more than 15 cases. Proceed till the end of file.
    Each case contains only one line of six real number h1, h2, d1, d2, a, b. h1 is the height of Building1, h2 is the height of Building2, d1 is the X-distance between Building1 and Building2, d2 is the X-distance between point B and Building1. These four numbers are in [0, 1000] , and satisfies d1 < d2. And a and b are in (0, 1000].

    Output

    If it is possible for Alex to land exactly on point B, print Yes, otherwise print No.

    Sample Input

    25 1 6 7 1 1
    4 3 1 2 1 1
    

    Sample Output

    Yes
    Yes
    

    HINT

    In case 2, Alex just glide over the building2 and do not crash onto it.

     1 #include<iostream>  
     2 #include<string.h>  
     3 #include<stdio.h>  
     4 #include<ctype.h>  
     5 #include<algorithm>  
     6 #include<stack>  
     7 #include<queue>  
     8 #include<set>  
     9 #include<math.h>  
    10 #include<vector>  
    11 #include<map>  
    12 #include<deque>  
    13 #include<list>  
    14 using namespace std;
    15 
    16 int main()
    17 {
    18     double h1,h2,d1,d2,a,b,x[2];
    19     while (scanf("%lf%lf%lf%lf%lf%lf",&h1,&h2,&d1,&d2,&a,&b)!=EOF)
    20     {
    21         if (h1/b-d2*d2>0) 
    22         {
    23         printf("No
    ");
    24         continue;
    25         }
    26         double derta=4*b*b*d2*d2-4*(a+b)*(b*d2*d2-h1);
    27         if (derta<0) 
    28         {
    29         printf("No
    ");
    30         continue;
    31         }
    32         x[0]=(2*b*d2+sqrt(derta))/(2*(a+b));
    33         x[1]=(2*b*d2-sqrt(derta))/(2*(a+b));
    34         if(x[0]<0&&x[1]<0)
    35         {
    36         printf("No
    ");
    37         continue;
    38         }
    39         int flag[2]={0,0};
    40         for(int i=0;i<2;i++)
    41         {
    42             if(d1-x[i]>0)
    43             {
    44                 //if((-b*pow(d1-x[i],2)+(-a*pow(x[i],2)+h1))>=h2)
    45                 if(b*(d1-d2)*(d1-d2)>=h2) 
    46                 {
    47                 flag[i]=1;
    48                 break;
    49                 } 
    50             }
    51             else
    52             {
    53                   if((-a*pow(d1,2)+h1)>=h2)
    54                 {
    55                 flag[i]=1;
    56                 break;
    57                 } 
    58             }
    59         }
    60            if (flag[0]==1||flag[1]==1) 
    61         printf("Yes
    ");
    62         else 
    63         printf("No
    ");
    64     }
    65     return 0;
    66 }
    View Code
  • 相关阅读:
    linux学习(三)输入输出重定向和管道功能、cat命令、more命令
    linux基础学习(二)ls命令以及文件访问权限例(-rw-r-r--)
    c语言的全排列
    linux基础学习(一)常用命令:date、pwd、cd、cal、who、wc等等
    用linux编译并运行c文件
    安装linux虚拟机
    安装quickLook插件以及解决如何不能读取offic问题
    java:数据结构(四)二叉查找树以及树的三种遍历
    java:数据结构复习(三)链表队列
    数据结构java学习(三)循环队列
  • 原文地址:https://www.cnblogs.com/qscqesze/p/3871002.html
Copyright © 2011-2022 走看看