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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| #include<bits/stdc++.h> #define x first #define y second #define PII pair<double, double> using namespace std; const int N = 50010 + 5; const double eps = 1e-12; const double PI = acos(-1); int n; PII q[N]; struct Circle{ PII p; double r; }; int sign(double x) { if(fabs(x) < eps) return 0; if(x < 0) return -1; return 1; } int dcmp(double x, double y) { if(fabs(x - y) < eps) return 0; if(x < y) return -1; return 1; } PII operator- (PII a, PII b) { return {a.x - b.x, a.y - b.y}; } PII operator+ (PII a, PII b) { return {a.x + b.x, a.y + b.y}; } PII operator* (PII a, double b) { return {a.x * b, a.y * b}; } PII operator/ (PII a, double b) { return {a.x / b, a.y / b}; } double operator* (PII a, PII b) { return a.x * b.y - a.y * b.x; } PII rotate(PII a, double b) { return {a.x * cos(b) + a.y * sin(b), -a.x * sin(b) + a.y * cos(b)}; } double get_dist(PII a, PII b) { double dx = a.x - b.x; double dy = a.y - b.y; return sqrt(dx * dx + dy * dy); }
PII get_line_intersection(PII p, PII v, PII q, PII w) { PII u = p - q; double t = w * u / (v * w); return p + v * t; } pair<PII, PII> get_line(PII a, PII b) { return {(a + b) / 2, rotate(b - a, PI / 2)}; } Circle get_circle(PII a, PII b, PII c) { pair<PII, PII> u = get_line(a, b), v = get_line(a, c); PII p = get_line_intersection(u.x, u.y, v.x, v.y); return {p, get_dist(p, a)}; } int main() { scanf("%d", &n); for(int i = 0;i < n;i ++) scanf("%lf%lf", &q[i].x, &q[i].y); double a, p; scanf("%lf%lf", &a, &p); for(int i = 0;i < n;i ++) { q[i] = rotate(q[i], a / 180 * PI); q[i].x /= p; } random_shuffle(q, q + n); Circle c({q[0], 0}); for(int i = 1;i < n;i ++) if(dcmp(c.r, get_dist(c.p, q[i])) < 0) { c = {q[i], 0}; for(int j = 0;j < i;j ++) if(dcmp(c.r, get_dist(c.p, q[j])) < 0) { c = {(q[i] + q[j]) / 2, get_dist(q[i], q[j]) / 2}; for(int k = 0;k < j;k ++) { if(dcmp(c.r, get_dist(c.p, q[k])) < 0) { c = get_circle(q[i], q[j], q[k]); } } } } printf("%.3lf", c.r); return 0; }
|