Advertisement
Dimaush

W

Oct 23rd, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     freopen("f.in", "r", stdin); freopen("f.out", "w", stdout);
  9.     cin.tie(nullptr); cout.tie(nullptr);
  10.     ios_base::sync_with_stdio(false);
  11.     cout << setprecision(20);
  12.  
  13.     int x_1, y_1, x_2, y_2;
  14.     int u, t;
  15.     int v_x, v_y, w_x, w_y;
  16.     cin >> x_1 >> y_1 >> x_2 >> y_2;
  17.     cin >> u >> t;
  18.     cin >> v_x >> v_y;
  19.     cin >> w_x >> w_y;
  20.  
  21.     long long a, b, c, D;
  22.     a = u * u - v_x * v_x - v_y * v_y;
  23.     b = 2 * (v_x * (x_2 - x_1) + v_y * (y_2 - y_1));
  24.     c = -((x_2 - x_1) * (x_2 - x_1) + (y_2 - y_1) * (y_2 - y_1));
  25.     D = b * b - 4 * a * c;
  26.     double t0 = (sqrt(D) - b) / (2 * a);
  27.     if (t0 <= t) {
  28.         cout << t0 << endl;
  29.     } else {
  30.         x_1 = x_1 + t * v_x - t * w_x;
  31.         y_1 = y_1 + t * v_y - t * w_y;
  32.         a = u * u - w_x * w_x - w_y * w_y;
  33.         b = 2 * (w_x * (x_2 - x_1) + w_y * (y_2 - y_1));
  34.         c = -((x_2 - x_1) * (x_2 - x_1) + (y_2 - y_1) * (y_2 - y_1));
  35.         D = b * b - 4 * a * c;
  36.         cout << (sqrt(D) - b) / (2 * a) << endl;
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement