HDU----1155
来源:互联网 发布:三工序雕刻机怎么编程 编辑:程序博客网 时间:2024/05/17 17:38
Description
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.
Input
350 20 30 75375 20 30 75400 20 30 75425 20 30 75450 20 30 75400 20 30 50400 20 30 80400 20 30 850 0 0 0
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.
这个这就是一个简单题,主要就是物理的能量守恒,输入四个数k, l, s, w分别表示弹簧系数,弹簧长度,形变量, 体重,然后求出重力做功, 然后减去弹簧做功,然后求出速度,判断速度大小
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<math.h>using namespace std;#define N 1100#define g 9.81int main(){ double k, l, s, w; while(scanf("%lf%lf%lf%lf", &k,&l,&s,&w)!=EOF) { if(k==0 && l==0 && s==0 && w==0) break; double e=w*g*s; if(s>l) e-=k*(s-l)*(s-l)/2; if(e<0) { printf("Stuck in the air.\n"); continue; } else { double v; v=sqrt(2*e/w); if(v>=10) printf("Killed by the impact.\n"); else printf("James Bond survives.\n"); } } return 0;}
- HDU----1155
- HDU 1155
- hdu 1155(物理题)
- HDU 1155 Bungee Jumping
- 【HDU 杭电 1155】
- HDU-1155-Bungee Jumping
- hdu 1155 Bungee Jumping
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- MediaRecorder录制音频及代码的抽取封装
- CSS实现点击事件样式
- NEFU 84 扩展欧几里得
- [又值奥运季] 2016年里约奥运会--8月19日赛事
- 远程登录时安装MATLAB的License Manager Error -103错误
- HDU----1155
- Kylin 环境 搭建 报错 <----寻求解决方案
- win10、vs2015pro,matlab2016a安装libsvm-3.21、svm入门实例
- Android之自定义实现BaseAdapter(通用适配器二)
- 稳定排序与不稳定排序
- java面试技巧注意事项
- ubuntu下配置dns
- java中类的加载顺序介绍(ClassLoader)
- C#的SqlDbHelper(数据库访问公共接口)