UVA 10868(p345)----Bungee Jumping

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

你可能感兴趣的:(UVA 10868(p345)----Bungee Jumping)