比较简单的一道题目,按照绳子的长度和桥的长度大小分为两种情况来考虑,当绳子的长度大于等于桥的长度的时候,人会直接做自由落体运动,计算出人到达桥面的速度,然后判断即可,如果桥的长度大于绳子的长度,那么从刚开始一直到绳子的长度人是自由落体运动的,当超过绳子的长度的时候既要考虑人自身的重力也要考虑绳子的拉力,积分即可,具体实现见如下代码:
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<deque>
#include<functional>
using namespace std;
double k, l, s, w;
double g = 9.81;
int main(){
while (cin >> k >> l >> s >> w){
if (k == 0 && l == 0 && s == 0 && w == 0) break;
if (l >= s){
double s_v = 2 * g*s;
if (s_v > 100) cout << "Killed by the impact.\n";
else cout << "James Bond survives.\n";
}
else{
double s_v1 = 2 * g*l;
double s_v2 = s_v1-k*(s - l)*(s - l) / w+2*g*(s-l);
if (s_v2<0) cout << "Stuck in the air.\n";
else if (s_v2>100) cout << "Killed by the impact.\n";
else cout << "James Bond survives.\n";
}
}
return 0;
}