比较简单的一道题目,按照绳子的长度和桥的长度大小分为两种情况来考虑,当绳子的长度大于等于桥的长度的时候,人会直接做自由落体运动,计算出人到达桥面的速度,然后判断即可,如果桥的长度大于绳子的长度,那么从刚开始一直到绳子的长度人是自由落体运动的,当超过绳子的长度的时候既要考虑人自身的重力也要考虑绳子的拉力,积分即可,具体实现见如下代码:
#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;
}
这是一篇关于UVa 10868 - Bungee Jumping问题的解析。根据绳子和桥的长度,文章分别讨论了两种情况:绳长>=桥长时的自由落体运动和绳长<桥长时的重力与绳索拉力的综合影响。通过计算到达桥面的速度并进行积分分析,提供了具体的解决方案。

209

被折叠的 条评论
为什么被折叠?



