UVA 10868(p345)----Bungee Jumping

本文深入探讨了利用C++编程语言解决复杂问题的策略,重点介绍了数值方法、动态规划、贪心算法等经典算法在实际应用中的优化技巧。通过实例分析,展示了如何在特定问题场景下选择合适的算法,以及如何通过代码实现来提升程序性能。
#include<iostream>
#include<cstdio>
#include<cmath>
#define g 9.81
using namespace std;
int main()
{
    double k,l,s,w;
    while(scanf("%lf%lf%lf%lf",&k,&l,&s,&w)==4&&(k+l+s+w))
    {
        if(s<=l)
        {
            double v=2*s*g;
            if(v<=100.0) printf("James Bond survives.\n");
            else printf("Killed by the impact.\n");
        }
        else
        {
            double tmp1=w*g*s;
            double tmp2=0.5*k*(s-l)*(s-l);
            if(tmp1<tmp2) printf("Stuck in the air.\n");
            else
            {
                double tmp=-0.5*k*(s-l)*(s-l)+w*g*(s-l)+0.5*w*2*g*l;
                double v=tmp*2/ w;
                if(v<=100.0) printf("James Bond survives.\n");
                else printf("Killed by the impact.\n");
            }
        }
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值