#include #include #include #include using namespace std; const double EX[7] = { -1, 1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235 }; vector p(7); double expected(int n) { if (n <= 6) { return EX[n]; } vector count(n + 1); for (int i = 1; i <= 6; ++i) { count[i] = EX[i]; } for (int i = 7; i <= n; ++i) { count[i] = 0.0; for (int k = 1; k <= 6; ++k) { count[i] += (1.0 + count[i - k]) * p[k]; } } return count[n]; } int main() { p[1] = EX[2] - 1.0; p[2] = EX[3] - EX[2] * p[1] - 1.0; p[3] = EX[4] - EX[3] * p[1] - EX[2] * p[2] - 1.0; p[4] = EX[5] - EX[4] * p[1] - EX[3] * p[2] - EX[2] * p[3] - 1.0; p[5] = EX[6] - EX[5] * p[1] - EX[4] * p[2] - EX[3] * p[3] - EX[2] * p[4] - 1.0; p[6] = 1.0 - accumulate(&p[1], &p[5] + 1, 0.0); int t; cin >> t; vector n(t); for (int i = 0; i < t; ++i) { cin >> n[i]; cout << fixed << setprecision(10) << expected(n[i]) << endl; } return 0; }