题意:James Bond 为了逃命,要绑着橡皮绳从桥上跳下,若他不能到达地面则输出Stuck in the air. 若到达地面的速率大于10m/s 输出Killed by the impact. 若到达地面速率小于10m/s 输出James Bond survives.
#include <iostream>
using namespace std;
const float g = 9.81f;
int main()
{
float k, l, s, w;
float v2;
while(scanf("%f%f%f%f", &k, &l, &s, &w))
{
if(!k && !l && !s && !w) break;
if(l >= s) { // 当绳长大于桥的高度时,全程自由落体运动,直接求落地速率,并进行判断
v2 = 2*g*s;
if(v2 > 100) { printf("Killed by the impact.\n"); }
else { printf("James Bond survives.\n"); }
continue;
}
else {
if(k*(s-l)*(s-l)/2 > w*g*s) /* 假设到达地面时,如果此时的弹性势能已经大于最初人
总共的重力势能,说明人的动能为负,这是不可能的,
说明人在到达地面之前,速率就已经减到0了。*/
{ printf("Stuck in the air.\n"); continue; }
v2 = 2*g*s-k*(s-l)*(s-l)/w; // 能够到达地面时求到达地面时的速率的平方。
if(v2 > 100) { printf("Killed by the impact.\n"); }
else { printf("James Bond survives.\n"); }
continue;
}
}
return 0;
}