View Code of Problem 104

#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    double n,v1,v2,t,t1=0.0;
    while(cin>>n>>v1>>v2>>t){
        n=n*1000;
        if(v2>v1)
            cout<<"NO"<<endl;
        else{
            if(n/abs(v1-v2)<=t){
                t1=n*1.0/abs(v1-v2);
                cout<<fixed<<setprecision(2)<<t1<<endl;
            }
            else
                cout<<"NO"<<endl;
        }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 104