#include <iostream> #include <iomanip> using namespace std; int main() { int n,v1,v2; float t; while(cin >>n>>v1>>v2>>t){ if(v1>0&&v2>0){ if(v1<=v2){ cout << "NO"<<endl; } else{ if((float)n*1000.0/(v1-v2)<=t){ cout <<fixed<<setprecision(2)<<(float)n*1000.0/(v1-v2)<<endl; } else{ cout << "NO"<<endl; } } } else if(v1<=0&&v2>0){ cout << "NO"<<endl; } else if(v1>0&&v2<=0){ if((float)n*1000.0/(v1-v2)<=t){ cout <<fixed<<setprecision(2)<<(float)n*1000.0/(v1-v2)<<endl; } else{ cout << "NO"<<endl; } } else if(v1<=0&&v2<=0){ if(v1-v2>0&&(float)n*1000.0/(v1-v2)<=t){ cout <<(float)n*1000.0/(v1-v2)<<endl; } else{ cout << "NO"<<endl; } } } return 0; } |
Double click to view unformatted code.