HOJ 2105 Bungee Jumping

来源:互联网 发布:杭州g20知乎 编辑:程序博客网 时间:2024/04/18 12:06

http://acm.hit.edu.cn/hoj/problem/view?id=2105

已知绳子劲度系数为k 原长为l 桥高为s某人体重为w

重力加速度g=9.81

剩下是一个物理问题:

 

  原长小于桥高

kΔl>2wgs//劲度系数太大在空中下不来

v=sqrt(2*g*s-((k*(s-l)*(s-l)/w))); //末速度v>10就挂了

  原长大于等于桥高

看末速度

 

#include <stdio.h>#include <math.h>int main(){    double k, l, s, w, v;    const double g = 9.81;    while (scanf("%lf %lf %lf %lf", &k, &l, &s, &w) != EOF)    {        if ( (k == 0) && (l == 0) && (s == 0) && (w == 0) )            break;        if (l < s)        {            if (k * (s - l) * (s - l) > 2 * w * g * s)            {                printf("Stuck in the air.\n");                continue;            }            v = sqrt( 2 * g * s - ( (k * (s - l) * (s - l) / w) ) );            if (v > 10)            {                printf("Killed by the impact.\n");            }            else            {                printf("James Bond survives.\n");            }        }        else if (2 * g * s > 100)        {            printf("Killed by the impact.\n");        }        else            printf("James Bond survives.\n");    }    return 0;}


 

 

原创粉丝点击