View Code of Problem 104

#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	double n,v1,v2,t;
	while(cin>>n>>v1>>v2>>t){
		double tt=-1;
		if(v1!=v2){
			tt=n*1000/(v1-v2);
		}
		else{
			if(n==0){
				tt=0;
			}
		}
		if(tt>=0&&tt<=t){
			printf("%.2f\n",tt);
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 104