Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. double Equal(double a, double b)
  8. {
  9. return abs(a - b) < 10e-7;
  10. }
  11.  
  12. bool Bigger(double a, double b)
  13. {
  14. return !Equal(a, b) && a > b;
  15. }
  16.  
  17. int main()
  18. {
  19. //freopen("Text.txt", "r", stdin);
  20.  
  21. double h, t, v, x;
  22. scanf("%lf%lf%lf%lf", &h, &t, &v, &x);
  23.  
  24. double minT;
  25.  
  26. if (Bigger(x * t, h) || Equal(x * t, h))
  27. minT = 0;
  28. else
  29. minT = (double)(h - x * t) / (v - x);
  30.  
  31. double maxT;
  32.  
  33. if (Bigger(h, x * t) || Equal(h, x * t))
  34. maxT = t;
  35. else
  36. maxT = (double)h / x;
  37.  
  38. printf("%.10lf %lf", minT, maxT);
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement