#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; void solve(const vector& s, int len, vector > >& dp) { int n = s.size(); dp.assign(n, vector >(n, vector(len, 0.0))); dp[0][0][0] = 1.0; for(int i=0; i> n >> len; len *= 60; vector s(n); for(int i=0; i> a >> c >> b; s[i] = a * 60 + b; } vector power(n, 1); for(int i=1; i > > dp1, dp2; solve(s, len, dp1); reverse(s.begin(), s.end()); solve(s, len, dp2); double ret = 0.0; for(int i=0; i=0; --j){ tmp += dp2[n-1-i][b][len-1-j]; ret += dp1[i][a][j] * tmp * power[a+b] * power[n-1-a-b]; } } } } for(int i=1; i<=n; ++i) ret /= i; printf("%.10f\n", ret); return 0; }