Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <map>
- #include <iomanip>
- using namespace std;
- const int N = 2e5 + 7, INF = 1e8;
- long double v1, v2, t, d, l,r, mid;
- bool check(long double v) {
- return (v1 * t) / (v - v1) - (v2 * t) / (v - v2) <= d;
- }
- int main()
- {
- cin >> v1 >> v2 >> t >> d;
- if (v1 < v2) {
- swap(v1, v2);
- }
- l = v1;
- r = 200;
- for (int i = 0; i < 100; i++) {
- mid = (l + r) / 2;
- if (check(mid)) {
- r = mid;
- }
- else {
- l = mid;
- }
- }
- cout << fixed << setprecision(10) << l;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement