Advertisement
bibaboba12345

лошарский бп

Oct 15th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <map>
  5. #include <iomanip>
  6. using namespace std;
  7. const int N = 2e5 + 7, INF = 1e8;
  8. long double v1, v2, t, d, l,r, mid;
  9.  
  10. bool check(long double v) {
  11. return (v1 * t) / (v - v1) - (v2 * t) / (v - v2) <= d;
  12. }
  13.  
  14. int main()
  15. {
  16. cin >> v1 >> v2 >> t >> d;
  17. if (v1 < v2) {
  18. swap(v1, v2);
  19. }
  20. l = v1;
  21. r = 200;
  22. for (int i = 0; i < 100; i++) {
  23. mid = (l + r) / 2;
  24. if (check(mid)) {
  25. r = mid;
  26. }
  27. else {
  28. l = mid;
  29. }
  30. }
  31. cout << fixed << setprecision(10) << l;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement