YT14-HDU-James跳桥

Problem Description

Once again, James Bond is fleeing from some evil people who want to see him dead. Fortunately, he has left a bungee rope on a nearby highway bridge which he can use to escape from his enemies. His plan is to attach one end of the rope to the bridge, the other
end of the rope to his body and jump off the bridge. At the moment he reaches the ground, he will cut the rope, jump into his car and be gone.

Unfortunately, he had not had enough time to calculate whether the bungee rope has the right length, so it is not clear at all what is going to happen when he jumps off the bridge. There are three possible scenarios:

The rope is too short (or too strong), and James Bond will never reach the ground.

The rope is too long (or too weak), and James Bond will be going too fast when he touches the ground. Even for a special agent, this can be very dangerous. You may assume that if he collides at a speed of more than 10 m/s, he will not survive the impact.

The rope‘s length and strength are good. James Bond touches the ground at a comfortable speed and can escape.

As his employer, you would like to know whether James Bond survives or whether you should place a job ad for the soon-to-be vacant position in the local newspaper. Your physicists claim that:

The force with which James is pulled towards the earth is

9.81 * w,

where w is his weight in kilograms and 9.81 is the Earth acceleration in meters over squared seconds.

Mr. Bond falls freely until the rope tautens. Then the force with which the bungee rope pulls him back into the sky depends on the current length of the rope and is

k * Δl,

where Δl is the difference between the rope‘s current length and its nominal, unexpanded length, and k is a rope-specific constant.

Given the rope‘s strength k, the nominal length of the rope l in meters, the height of the bridge s in meters, and James Bond‘s body weight w, you have to determine what is going to happen to our hero. For all your calculations, you may assume that James Bond
is a point at the end of the rope and the rope has no mass. You may further assume that k, l, s, and w are non-negative and that s < 200.

The input contains several test cases, one test case per line. Each test case consists of four floating-point numbers (k, l, s, and w) that describe the situation. Depending on what is going to happen, your program must print "Stuck in the air.", "Killed by
the impact.", or "James Bond survives.". Input is terminated by a line containing four 0s, this line should not be processed.

Sample Input

350 20 30 75
375 20 30 75
400 20 30 75
425 20 30 75
450 20 30 75
400 20 30 50
400 20 30 80
400 20 30 85
0 0 0 0

Sample Output

Killed by the impact.
James Bond survives.
James Bond survives.
James Bond survives.
Stuck in the air.
Stuck in the air.
James Bond survives.
Killed by the impact.

代码如下:

#include <iostream>
#include <cmath>
using namespace std;
const double g=9.81;                   //重力加速度
int main()
{
    double k,l,s,w;
    double E0,E1,E2,E4;
    while (cin>>k>>l>>s>>w)
    {
        if (k==0&&l==0&&s==0&&w==0)
            break;
        E0=0.5*k*(s-l)*(s-l);          //弹性势能
        E1=w*g*s;                      //重力势能
        E2=0.5*w*10*10;                //最大动能
        E4=E1-E0;                      //重力势能与弹力势能抵消后剩下的支持JAMES下落的能量
        if (l>s)
        {
            if (E1>E2)
                cout<<"Killed by the impact."<<endl;
            else
                cout<<"James Bond survives."<<endl;
        }
        else
        {
            if(E0>E1)
                cout<<"Stuck in the air."<<endl;
            else if(E4<E2)
                cout<<"James Bond survives."<<endl;
            else
                cout<<"Killed by the impact."<<endl;
        }
    }
    return 0;
}

运行结果:

简单的物理问题,,,好在我高中的班主任是物理老师,一些能量间的转换什么的还是记得一些的,可是我忘光了物理公式。。。

时间: 2024-12-11 16:49:32

YT14-HDU-James跳桥的相关文章

Caocao&#39;s Bridges HDU - 4738 找桥

题意: 曹操在赤壁之战中被诸葛亮和周瑜打败.但他不会放弃.曹操的军队还是不擅长打水仗,所以他想出了另一个主意.他在长江上建造了许多岛屿,在这些岛屿的基础上,曹操的军队可以轻易地攻击周瑜的军队.曹操还修建了连接岛屿的桥梁.如果所有的岛屿都用桥连接起来,曹操的军队就可以很方便地部署在这些岛屿之间.周瑜无法忍受,他想毁掉曹操的一些桥梁,把一个或多个岛屿与其他岛屿分开.周瑜身上只有一颗炸弹,是诸葛亮留下的,所以他只能毁掉一座桥.周瑜必须派人带着炸弹去炸毁那座桥.桥上可能有警卫.轰炸队的士兵人数不能少于一

HDU - 2460 Network(桥+LCA)

题目大意:给出一张图,现在要往这张图上加边,问加完边后,这张图还有多少条桥 解题思路:求出连通分量,压缩成点,用桥连接,形成了棵树 每次添加边时,就找一下是否在同一个强连通分量内,如果在同一个强连通分量内,那么桥的数量不变 反之,求出两个点的LCA,并且把LCA到这两个点的桥全部去掉(因为加边后,形成了环,构成了一个新的强连通分量了) #include <cstdio> #include <cstring> using namespace std; #pragma comment(

【游戏】【鬼泣4】边玩边记(三)

终于通关了.1.有迷雾的迷宫那一关.迷路了,本来来到了正确的路,却忘了怎么走.关键词:跳桥.桥下.楼梯下.上山.2.最后任务的老头子真的没想到这么好杀,直接轰至渣.最后那个大石头人,摸索了很久才明白,第一拳落下,需要躲闪开,然后对着拳头用L键,第二拳,在拳头打来时对着拳头按L键,然后它就屈服了.3.女主角这身材……这相貌……唉…… (此篇博客搬迁于百度空间,原发布日期为:2009-09-07)

張國榮鮮為人知的52個電影秘密

1,<色情男女>主角原型是谁? 仔细看的话,会发现<色情男女>刘青云饰演的“尔东升”有一张被偷怕和同性朋友的亲密照 <色情男女>说的是满怀理想的年轻导演阿星(张国荣饰)由于处境艰难沦落执导三级片,他接受现实后,便决定拍出有质量不低俗三级片故事.一直来,这部电影都被观众认为是导演尔冬升在夫子自道,事实上,故事原型并不是他,尔冬升接受访问时都表示另有其人,也常常出于好意不愿说出对方名字. 毕竟拍三级片不是什么值得显耀的事.化名拍戏更是见怪不怪.电影里有一段情节,一导演得意的

阿甘正传&mdash;&mdash;影评

第一次看<阿甘正传>的时候,惊叹于影片情节与美国众多历史事件的惊人巧合,妒忌弱智的阿甘接连不断的好运气,对珍妮的频繁出走感到不解,为阿甘执着的爱情所感动.    后来发现香港明珠台重放次数最多的恐怕要数<阿甘正传>了,央视六频道也经常重播,昨晚也播了,每次重看,我都会陷入一种油然而生的感动中,有时候即使不看影片,开头及结尾的音乐一旦响起,总会产生一种莫名奇妙的感动. <阿甘正传>原著小说跟影片基本是两码事,导演对原著小说的改编非常坚决,几乎全盘推倒,重新来过.原著小说中

JSP学习笔记--内置对象

1. JSP内置对象分类 (1)application:javax.servlet.ServletContext的实例,该实例代表JSP所属的WEB应用本身,可用于JSP页面,或者Servlet之间交换信息.常用的方法有getAttribute(String attName), setAttribute(String attName,String attValue)和getInitParameter(String Param)等. (2)config:javax.servlet.ServletC

【读后感】读《牛奶可乐经济学》后感

最近一段时间一直忙着项目的事情,没能抽出来时间看书.过年正好是一个调整自己的机会,去图书馆借了一大摞书回来,利用一个下午的时间看完了<牛奶可乐经济学>,深有感触,这里赶紧记录一下. 本书的作者是Robert H.Frank,是通俗经济学的鼻祖.此人擅长用各种实际生活中的案例而不是枯燥的图表公式来讲述经济学的一些基本知识,帮助经济学领域没有基础的人很快的学会一些基本的经济理论.其中一些有趣的案例确实值得称道. 最让我记忆深刻的是关于美国康奈尔大学自杀率的.美国康奈尔大学的自杀率其实很低,是全美大

牛奶可乐经济学(一)

解开人类日常行为之谜 取款机制造商必须给普通的街头取款机装配带点字盲文的小键盘,因为所有机器都造成一个样子,成本更低廉.要不然的话就要把两类机器都分开,保证合适的机器安装到合适的地方. 生产两种不同提款机的成本,远远大于合理的预期收益. 机会成本 从事一项活动的机会成本,是指你为了从事这件事而放弃其他事情的价值. 为什么曼哈顿的居民大多粗鲁没有耐心,而堪萨斯首府托皮卡的居民却友善而谦恭呢? 曼哈顿人的工资水平最高,要做的事情很多,时间的机会成本很高. 有例外才能证明规律的存在. 成本效益原则 成

HDU 1245 Saving James Bond

计算几何+SPFA 我已经不想看我的提交记录了.... HDU 我起码WA了2页.... 都是浮点数惹的祸. const double eps=1e-4; abs(a-b)<=eps; 这样来判断相等. 总共 n 条鳄鱼,最多有 n*(n+1)/2 条路. 抽象化处理. 把 中心的起点当作 起点0 : 最多有 n+1 条路. 把鳄鱼和周围的边界的终点都当作 n+1 ; 最多有 n+1 条 总共就只存在 n+2个点. 就是计算0 和 n+1 的最短距离. 有个小优化,就是当 跳跃距离能够直接跳到岸