|
| 1 | +#include <bits/stdc++.h> |
| 2 | + |
| 3 | +using namespace std; |
| 4 | + |
| 5 | +int const N = 1e4 + 10; |
| 6 | + |
| 7 | +struct point { |
| 8 | + double x, y, z; |
| 9 | + |
| 10 | + point() {} |
| 11 | + |
| 12 | + point(double x, double y, double z) : x(x), y(y), z(z) {} |
| 13 | + |
| 14 | + bool operator==(const point &p) const { |
| 15 | + return x == p.x && y == p.y && z == p.z; |
| 16 | + } |
| 17 | + |
| 18 | + point operator-(const point &p) const { |
| 19 | + return point(x - p.x, y - p.y, z - p.z); |
| 20 | + } |
| 21 | + |
| 22 | + point operator+(const point &p) const { |
| 23 | + return point(x + p.x, y + p.y, z + p.z); |
| 24 | + } |
| 25 | + |
| 26 | + point operator*(const double &o) const { |
| 27 | + return point(x * o, y * o, z * o); |
| 28 | + } |
| 29 | + |
| 30 | + double dist(const point &p) const { |
| 31 | + return sqrt(pow(x - p.x, 2) + pow(y - p.y, 2) + pow(z - p.z, 2)); |
| 32 | + } |
| 33 | +} points[N]; |
| 34 | +point p; |
| 35 | + |
| 36 | +int n; |
| 37 | +double vp, vs, t[N]; |
| 38 | + |
| 39 | +int main() { |
| 40 | + scanf("%d", &n); |
| 41 | + for(int i = 0; i <= n; ++i) |
| 42 | + scanf("%lf %lf %lf", &points[i].x, &points[i].y, &points[i].z); |
| 43 | + scanf("%lf %lf", &vp, &vs); |
| 44 | + scanf("%lf %lf %lf", &p.x, &p.y, &p.z); |
| 45 | + |
| 46 | + if(p == points[0]) { |
| 47 | + puts("YES"); |
| 48 | + puts("0.0000000000"); |
| 49 | + printf("%0.10lf %0.10lf %0.10lf\n", p.x, p.y, p.z); |
| 50 | + return 0; |
| 51 | + } |
| 52 | + |
| 53 | + for(int i = 1; i <= n; ++i) |
| 54 | + t[i] = points[i].dist(points[i - 1]) / vs + t[i - 1]; |
| 55 | + |
| 56 | + for(int i = 1; i <= n; ++i) { |
| 57 | + if(p.dist(points[i]) / vp - 1e-9 < t[i]) { |
| 58 | + double l = 0, r = 1, mid; |
| 59 | + point res; |
| 60 | + for(int j = 0; j < 100; ++j) { |
| 61 | + mid = (l + r) / 2; |
| 62 | + point cur = points[i - 1] + (points[i] - points[i - 1]) * mid; |
| 63 | + |
| 64 | + if(p.dist(cur) / vp - 1e-15 < points[i - 1].dist(cur) / vs + t[i - 1]) |
| 65 | + res = cur, r = mid; |
| 66 | + else |
| 67 | + l = mid; |
| 68 | + } |
| 69 | + |
| 70 | + puts("YES"); |
| 71 | + printf("%0.10lf\n", p.dist(res) / vp); |
| 72 | + printf("%0.10lf %0.10lf %0.10lf\n", res.x, res.y, res.z); |
| 73 | + |
| 74 | + return 0; |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + puts("NO"); |
| 79 | + |
| 80 | + return 0; |
| 81 | +} |
0 commit comments