#include<stdio.h> int main() { int n, a, b; double t, m; while(scanf("%d%d%d%lf", &n, &a, &b, &m) != EOF) { if(b == a) { printf("NO\n"); continue; } if(b >= 0 && a >= 0) { b -= a; if(b < 0) { t = (double)(n*1000) / (-b); if(m >= t) printf("%.2lf\n", t); else printf("NO\n"); } else printf("NO\n"); } else if(b <= 0 && a <= 0) { b -= a; if(b < 0) { t = (double)(n*1000) / (-b); if(m >= t) printf("%.2lf\n", t); else printf("NO\n"); } else printf("NO\n"); } else if(b < 0 && a > 0) { b = a-b; t = (double)(n*1000) / b; if(m >= t) printf("%.2lf\n", t); else printf("NO\n"); } else printf("NO\n"); } return 0; } |
Double click to view unformatted code.