View Code of Problem 104

#include <iostream>
using namespace std;
int main(){
	int n,v1,v2,t,k;
	double time;
	while(cin>>n>>v1>>v2>>t){
		int flag=1;
		if(v1<v2)
			flag=0;
		else if(v1==v2&&n>0)
			flag=0;
		else{
			k=v1-v2;
			time=n*1000.0/k;
			if(time>t)
				flag=0;
		}
		if(flag)
			printf("%.2lf\n",time);
		else
			printf("NO\n");	
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 104