#include<stdio.h> #include<string.h> int main() { int n,v1,v2,t;double ti; while(scanf("%d%d%d%d",&n,&v1,&v2,&t)!=EOF) { if(v1<0) { if(v2>0) { printf("NO\n"); } if(v2<0) { if(v1>v2) {ti=(double)n*1000.0/(v1-v2); if(ti>t) printf("NO\n"); else printf("%.2f\n",ti); } else printf("NO\n"); } } else{ if(v2<0) { ti=(double)n*1000.0/(v1-v2); if(ti>t) printf("NO\n"); else printf("%.2f\n",ti); } else { if(v2>v1) printf("NO\n"); else {ti=(double)n*1000.0/(v1-v2); if(ti>t) printf("NO\n"); else printf("%.2f\n",ti); } } } } } |
Double click to view unformatted code.