1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| #include <bits/stdc++.h> #define EPS 1e-6 #define PI acos(-1) using namespace std;
typedef long long ll;
int n, m, k;
struct Point { double x, y; Point() {} Point(double x, double y) : x(x), y(y) {} double abs() const { return hypot(x, y); } double arg() const { return atan2(y, x); } Point operator*(double o) const { return Point(x * o, y * o); } Point operator+(const Point &o) const { return Point(x + o.x, y + o.y); } Point operator-(const Point &o) const { return Point(x - o.x, y - o.y); } bool operator<(const Point &o) const { return x < o.x - EPS || (x < o.x + EPS && y < o.y - EPS); } };
Point A, B; map<double, int> js;
int main() { scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y); scanf("%d", &n); double x, y, a, w; for (int i = 0; i < n; i++) { scanf("%lf%lf%lf%lf", &x, &y, &a, &w); if (abs(w) < EPS) continue; Point p = {x, y}; double v = -2; for (int j = 0; j <= 100; j++) { Point tp = (B - A) * (j / 100.0) + A; double arg = (tp - p).arg() - a; if (arg > 2 * PI) arg -= 2 * PI; while (arg < 0) arg += 2 * PI; if (arg > 2 * PI - arg) arg = 2 * PI - arg; double t = arg / w; v = v < -1 ? (tp - A).abs() / t : max(v, (tp - A).abs() / t); } js[v]++; } scanf("%d", &k); int sk = 0; double t = -10; for (map<double, int>::reverse_iterator it = js.rbegin(); it != js.rend(); it++) { if (sk + it->second > k) { t = it->first; break; } sk += it->second; } printf("%.4lf\n", t < -1 ? 0 : t); return 0; }
|