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\n");
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\n");
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\n");
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\n");
62         else
63         printf("No\n");
64     }
65     return 0;
66 }

时间: 2024-09-30 04:11:09

ZOJ 3235 Prototype的相关文章

UESTC 2014 Summer Training #11 Div.2

E - Prototype ZOJ 3235 把(d2,0)代入第二个方程可以得到一个方程:经过(d2,0)的抛物线的起点的方程 再把它和第一个方程联立,就能解出两条抛物线的交点,再验算:是否在0~d2范围内,是否在x=d1时会撞到building2 注意可能不需要滑行就能到达(d2,0),先特殊处理这种情况 一开始傻逼理解错题意,后来一直修改又去考虑了不会出现的情况,例如A=0,delta<0,最后才发现了我忘记打sqrt了!!! 这场比赛题略难...就不会做 当时还是比较慌,很怕过不了题,加

POJ1546 &amp; HDU 1335 &amp; ZOJ 1334 Basically Speaking(进制转换)

题目链接: POJ:http://poj.org/problem?id=1546 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1335 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=334 Description The Really Neato Calculator Company, Inc. has recently hired your team to help

为什么会有jQuery、Dojo、Ext、Prototype、YUI、Zepto这么多JS包?

目前流行的JS框架很多Dojo .Scriptaculous .Prototype .yui-ext .Jquery .Mochikit.mootools .moo.fx 等.当然还有很多我都不熟悉的框架,就没有列举. 很多人会在坛子里问,到底哪个框架好呢?哪个框架更牛x呢? 哪个框架OO 更舒服呢? 个人觉得,这是一个新手很容易犯的错误逻辑. 世界上任何东西,任何工具,都没有最好的这一个说法,只有适合和不适合. 我们要根据我们项目的真实需要来选择具有相关特性的框架. 一.JQuery推荐级别:

理清javascript中prototype、__proto__、Object、Function的关系,更好地理解原型继承

本文参考了http://www.blogjava.net/heavensay/archive/2013/10/20/405440.html这篇文章,对其内容作了个简单总结,形成了几条简单的结论,让读者更容易记住prototype.__proto__.Object.Function之间的关系. 结论1:Object.prototype只是一个普通对象,它是js原型链的最顶端. (typeof Object.prototype) === object;//true Object.prototype.

设计模式(四) 原型模式(Prototype)

1.定义 原型模式属于一种创建型模式,与其他创建型模式不同,原型模式不是直接构造对象,而是通过复制一个已经存在的实例返回新的实例. 2.适用性 为何要拷贝而不直接生成?我的理解是有些时候直接构造实例花费比较大,比如在构造对象的时候需要做大量的数据库查询,这样如果构造许多类似的对象还重复地查询数据库则开销很大,很没效率.直接拷贝现有的实例,在需要情况下做一些小的修改会显得高效许多. 3.结构 Prototype: 声明一个克隆自身的接口 ConcretePrototype:实现一个克隆自身的操作

概率dp ZOJ 3640

Help Me Escape Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3640 Appoint description:  System Crawler  (2014-10-22) Description Background     If thou doest well, shalt thou not be accepted? an

zoj 2156 - Charlie&#39;s Change

题目:钱数拼凑,面值为1,5,10,25,求组成n面值的最大钱币数. 分析:dp,01背包.需要进行二进制拆分,否则TLE,利用数组记录每种硬币的个数,方便更新. 写了一个 多重背包的 O(NV)反而没有拆分快.囧,最后利用了状态压缩优化 90ms: 把 1 cents 的最后处理,其他都除以5,状态就少了5倍了. 说明:貌似我的比大黄的快.(2011-09-26 12:49). #include <stdio.h> #include <stdlib.h> #include <

ZOJ 1718 POJ 2031 Building a Space Station 修建空间站 最小生成树 Kruskal算法

题目链接:ZOJ 1718 POJ 2031 Building a Space Station 修建空间站 Building a Space Station Time Limit: 2 Seconds      Memory Limit: 65536 KB You are a member of the space station engineering team, and are assigned a task in the construction process of the statio

ZOJ 3607 Lazier Salesgirl (贪心)

Lazier Salesgirl Time Limit: 2 Seconds      Memory Limit: 65536 KB Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling. She can sell the i-th customer a piece of bread for price pi. But she is so lazy