蹦极 Bungee Jumping
题目描述
输入格式
输出格式
样例 #1
样例输入 #1
350 20 30 75
375 20 30 75
400 20 30 75
425 20 30 75
450 20 30 75
400 20 30 50
400 20 30 80
400 20 30 85
0 0 0 0
样例输出 #1
Killed by the impact.
James Bond survives.
James Bond survives.
James Bond survives.
Stuck in the air.
Stuck in the air.
James Bond survives.
Killed by the impact.
分析
直接用机械能守恒就可以了~
代码
#include<bits/stdc++.h>
using namespace std;
const double g=9.81;//double!!!
double pg,pt,k,v;//v=v^2
double K,l,s,w;
int main()
{
while(cin>>K>>l>>s>>w)
{
if(K==0&&l==0&&s==0&&w==0)
{
break;
}
pg=w*g*s;//直接用公式算
pt=0.5*K*max(s-l,0.0)*max(s-l,0.0);
k=pg-pt;
v=2*k/w;
if(v<0)//被卡在半空中
{
printf("Stuck in the air.\n");
}
else
{
if(v>100)//他摔死了
{
printf("Killed by the impact.\n");
}
else//v^2<=100,安全着陆
{
printf("James Bond survives.\n");
}
}
}
return 0;
}
结束啦~