Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

I don't know why I am wrong

Posted by carltonlay at 2008-03-23 20:42:15 on Problem 2463
分析:
1)假如绳子长度比桥的高度大,那么根据v=(2*s/9.81)^0.5算出坠桥时的速度,比10大就Killed by the impact.否则就James Bond survives.
2)若第一个不成立,那么我就算当下落时,JAMES速度为0时,绳子伸长了多少,根据能量转换
w*9.81*(l+dl)=0.5*k*dl*dl,根据求根公式解出dl,然后比较dl+l(这时绳子最长时的长度)与s(桥高),如果dl+l<s,说明邦德在空中,否则,james的末动能T=w*9.81*s-0.5*k*(s-l)*(s-l),然后根据v=(2*T/w)^0.5,如果比10大Killed by the impact.否则James Bond survives.

BUT WHY WRONG!!!!!

#include<stdio.h>
#include<math.h>

int main()
{
	double k, l,s,w;

	scanf("%lf",&k);
	scanf("%lf",&l);
	scanf("%lf",&s);
	scanf("%lf",&w);

	while( !( k==0&&l==0&&s==0&&w==0) )
	{
		if( l >= s)
		{
			if( sqrt((2*s)/9.81)>10)
			{
				printf("Killed by the impact.\n");
			}
			else
				printf("James Bond survives.\n");
		}
		else
		{
			double dl =( 2*w*9.81+sqrt(4*w*w*9.81*9.81+8*k*w*9.81*l))/(2*k);
			if( dl + l < s)
				printf("Stuck in the air.\n");
			else
			{
				double t = w*9.81*s-k*(s-l)*(s-l)/2;
				double v = sqrt(2*t/w);
				if( v > 10)
				{
					printf("Killed by the impact.\n");
				}
				else		
					printf("James Bond survives.\n");
			}
		}
			scanf("%lf",&k);
	scanf("%lf",&l);
	scanf("%lf",&s);
	scanf("%lf",&w);
	}

	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator