View Code of Problem 104

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
	int n, v1, v2, t;
	float time;
	while (cin >> n >> v1 >> v2>>t) {
		int v = v1 - v2;
		if (v <= 0) {
			cout << "NO"<<endl;
		}
		else {
			time = n * 1000.0 / v;
			if (time <= t) {
				cout <<fixed<<setprecision(2) <<time << endl;
			}
			else {
				cout << "NO" << endl;
			}
			
		}
	}
}

Double click to view unformatted code.


Back to problem 104