View Code of Problem 104

#include<stdio.h>
#include<math.h>
void main()
{
	float n,v1,v2,t,T;
	while(scanf("%f%f%f%f",&n,&v1,&v2,&t)!=EOF){
	if(v2>=v1)
		printf("NO\n");
	else
	{
		if(v1>=0&&v2<0){
			T=n/(v1+abs(v2));
			if(T<=t)
				printf("%.2f\n",1000*T);
			else
				printf("NO\n");
		}
		else if(v1>=0&&v2>0)
		{
			T=n/(v1-v2);
			if(T<=t)
				printf("%.2f\n",1000*T);
			else
				printf("NO\n");
		}
		else if(v1<=0&&v2<0)
		{
			T=n/abs(v2-v1);
			if(T<=t)
				printf("%.2f\n",1000*T);
			else
				printf("NO\n");
		}
	}
	}
}

Double click to view unformatted code.


Back to problem 104