UVA 10868(p345)----Bungee Jumping

来源:互联网 发布:凯立德导航端口查询 编辑:程序博客网 时间:2024/05/01 06:28
#include<iostream>#include<cstdio>#include<cmath>#define g 9.81using 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;}

0 0
原创粉丝点击