View Code of Problem 104

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

int main(){
	int n,v1,v2,t,flag;
	double a;
	while(scanf("%d%d%d%d",&n,&v1,&v2,&t)!=EOF)
	{
		flag=0;
		a=1.0*n*1000/t;
		if(v1==v2)
			flag=0;
		else if(v1-v2< a)
				flag=0;
		else 	
				flag=1;

		if(flag==1)
			printf("%0.2f\n",1.0*n*1000/(v1-v2));		
		else
			printf("NO\n");
				
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 104