Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int main() {
- freopen("f.in", "r", stdin); freopen("f.out", "w", stdout);
- cin.tie(nullptr); cout.tie(nullptr);
- ios_base::sync_with_stdio(false);
- cout << setprecision(20);
- int x_1, y_1, x_2, y_2;
- int u, t;
- int v_x, v_y, w_x, w_y;
- cin >> x_1 >> y_1 >> x_2 >> y_2;
- cin >> u >> t;
- cin >> v_x >> v_y;
- cin >> w_x >> w_y;
- long long a, b, c, D;
- a = u * u - v_x * v_x - v_y * v_y;
- b = 2 * (v_x * (x_2 - x_1) + v_y * (y_2 - y_1));
- c = -((x_2 - x_1) * (x_2 - x_1) + (y_2 - y_1) * (y_2 - y_1));
- D = b * b - 4 * a * c;
- double t0 = (sqrt(D) - b) / (2 * a);
- if (t0 <= t) {
- cout << t0 << endl;
- } else {
- x_1 = x_1 + t * v_x - t * w_x;
- y_1 = y_1 + t * v_y - t * w_y;
- a = u * u - w_x * w_x - w_y * w_y;
- b = 2 * (w_x * (x_2 - x_1) + w_y * (y_2 - y_1));
- c = -((x_2 - x_1) * (x_2 - x_1) + (y_2 - y_1) * (y_2 - y_1));
- D = b * b - 4 * a * c;
- cout << (sqrt(D) - b) / (2 * a) << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement