Bungee Jumping---hdu1155(物理题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1155

题目很长,但是很容易理解,就是人从高s的桥上跳下来,手拉着长为l的绳子末端,如果绳子太短那么人将在空中输出Stuck in the air.

如果人落地速度大于10的话就死了,输出Killed by the impact.否则是活的输出James Bond survives.

简单的物理题:假如说人能到地上那么是重力势能转化成动能,其中会有绳子做负功;

G=mgh;

Wf=k*L*L/2;其中L是形变量;k是绳子的劲度系数;

G-Wf = ek = m*v*v/2

 

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
#define g 9.81
int main()
{
    double k, l, s, w, e, v;
    while(scanf("%lf%lf%lf%lf", &k, &l, &s, &w), k+l+s+w)
    {
        e = w*g*s;
        if(s>l)
            e=e-k*(s-l)*(s-l)/2;
        if(e<0)
        {
            printf("Stuck in the air.\n");
            continue;
        }
        v=sqrt(2*e/w);
        if(v>10)
            printf("Killed by the impact.\n");
        else
            printf("James Bond survives.\n");
    }
    return 0;
}
View Code

 

posted @ 2015-09-05 13:55  西瓜不懂柠檬的酸  Views(212)  Comments(0Edit  收藏  举报
levels of contents