/* -*- coding: utf-8 -*- * * 1413.cc: No.1413 Dynamic Sushi - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 12; const int NBITS = 1 << MAX_N; const double PI = acos(-1.0); const int CNT = 50; const double DINF = 1e60; /* typedef */ template struct Pt { T x, y; Pt() {} Pt(T _x, T _y) : x(_x), y(_y) {} Pt(const Pt &p) : x(p.x), y(p.y) {} Pt operator+(const Pt p) const { return Pt(x + p.x, y + p.y); } Pt operator-() const { return Pt(-x, -y); } Pt operator-(const Pt p) const { return Pt(x - p.x, y - p.y); } Pt operator*(T t) const { return Pt(x * t, y * t); } Pt operator/(T t) const { return Pt(x / t, y / t); } T dot(Pt v) const { return x * v.x + y * v.y; } T cross(Pt v) const { return x * v.y - y * v.x; } Pt mid(const Pt p) { return Pt((x + p.x) / 2, (y + p.y) / 2); } T d2() { return x * x + y * y; } double d() { return sqrt(d2()); } Pt rot(double th) { double c = cos(th), s = sin(th); return Pt(c * x - s * y, s * x + c * y); } Pt rot90() { return Pt(-y, x); } bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; } bool operator<(const Pt &pt) const { return x < pt.x || (x == pt.x && y < pt.y); } void print() { printf("(%d,%d)", x, y); } }; typedef Pt pt; typedef pair pdpt; struct Crc { pt cp; int r, v, a; Crc() {} void read() { scanf("%lf%lf%d%d%d", &cp.x, &cp.y, &r, &v, &a); } pt at(double t) const { double th = (t * v + a) * (PI / 180); return cp + pt(cos(th), sin(th)) * r; } pdpt meet(int w, pdpt &s) const { double st = s.first; pt sp = s.second; if (sp == cp) { double t = st + (double)r / w; return pdpt(t, at(t)); } double vd = (cp - sp).d(); double t0 = st + abs(vd - r) / w; double t1 = st + (vd + r) / w; for (int cnt = 0; cnt < CNT; cnt++) { double t = (t0 + t1) / 2; pt p = at(t); if (st + (p - sp).d() / w <= t) t1 = t; else t0 = t; } return pdpt(t1, at(t1)); } }; /* global variables */ Crc cs[MAX_N]; pdpt dp[NBITS][MAX_N]; /* subroutines */ template inline void setmin(T &a, T b) { if (a > b) a = b; } /* main */ int main() { int n, w; scanf("%d%d", &n, &w); int nbits = 1 << n; for (int i = 0; i < n; i++) cs[i].read(); for (int bits = 0; bits < nbits; bits++) fill(dp[bits], dp[bits] + n, pdpt(DINF, pt(0.0, 0.0))); dp[0][0] = pdpt(0.0, pt(0.0, 0.0)); for (int bits = 0; bits < nbits; bits++) for (int i = 0; i < n; i++) if (dp[bits][i].first < DINF) for (int j = 0, bj = 1; j < n; j++, bj <<= 1) if (! (bits & bj)) { pdpt d1 = cs[j].meet(w, dp[bits][i]); setmin(dp[bits | bj][j], d1); } double mint = DINF; for (int i = 0; i < n; i++) setmin(mint, dp[nbits - 1][i].first); printf("%.10lf\n", mint); return 0; }