您的位置:首页 > 其它

hdu 1155(物理题)

2013-04-26 18:49 483 查看
点击打开链接

分析:

当绳长大于桥高时,判断10m/s的动能与重力势能的大小,前者大于等于后者,摔死。。否则安全

当绳长小于等于桥高时,当弹性势能大于重力势能,飞上天。否则判断重力势能和弹性势能的差值与10m/s的动能的大小关系,当前者大于后者,摔死,否则安全。。

#include"stdio.h"
#include"string.h"
#define g 9.81
int main()
{
double k,s,l,w;
double e1,e2,e3;
while(scanf("%lf%lf%lf%lf",&k,&l,&s,&w)!=-1)
{
if(!k&&!l&&!s&&!w)break;
e1=0.5*w*100;//10m/s的动能
e2=w*s*g;//重力势能
e3=0.5*k*(s-l)*(s-l);//弹性势能
if(l>s)//绳长大于桥高
{
if(e2>e1)printf("Killed by the impact.\n");
else printf("James Bond survives.\n");
}
else
{
if(e2<e3)printf("Stuck in the air.\n");
else if(e2-e3>e1)printf("Killed by the impact.\n");
else printf("James Bond survives.\n");
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: