UVa 10868 - Bungee Jumping

这是一篇关于UVa 10868 - Bungee Jumping问题的解析。根据绳子和桥的长度,文章分别讨论了两种情况:绳长>=桥长时的自由落体运动和绳长<桥长时的重力与绳索拉力的综合影响。通过计算到达桥面的速度并进行积分分析,提供了具体的解决方案。
摘要由CSDN通过智能技术生成

比较简单的一道题目,按照绳子的长度和桥的长度大小分为两种情况来考虑,当绳子的长度大于等于桥的长度的时候,人会直接做自由落体运动,计算出人到达桥面的速度,然后判断即可,如果桥的长度大于绳子的长度,那么从刚开始一直到绳子的长度人是自由落体运动的,当超过绳子的长度的时候既要考虑人自身的重力也要考虑绳子的拉力,积分即可,具体实现见如下代码:

#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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值