#include #define GET_MACRO(a, b, c, NAME, ...) NAME #define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define rep2(i, a) rep3 (i, 0, a) #define rep3(i, a, b) for (int i = (a); i < (b); i++) #define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__) #define repr2(i, a) repr3 (i, 0, a) #define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define chmin(a, b) ((b) < a && (a = (b), true)) #define chmax(a, b) (a < (b) && (a = (b), true)) using namespace std; typedef long long ll; typedef long double D; const int maxdim = 256; int dim; typedef D mat[maxdim][maxdim]; mat M0, M1, M2, M3; void matmul(mat A, mat B, mat res) { memset(M0, 0, sizeof(M0)); rep (i, dim) rep (k, dim) rep (j, dim) { M0[i][j] += A[i][k] * B[k][j]; } memcpy(res, M0, sizeof(M0)); } void matpow(mat A, ll b, mat res) { memcpy(M1, A, sizeof(M1)); rep (i, dim) rep (j, dim) M2[i][j] = i == j; while (b > 0) { if (b & 1) matmul(M1, M2, M2); matmul(M1, M1, M1); b >>= 1; } memcpy(res, M2, sizeof(M2)); } void companion(vector a, mat res) { memset(res, 0, sizeof(res)); int n = a.size(); rep (i, n - 1) res[i][i + 1] = 1; rep (i, n) res[n - 1][i] = a[i]; res[n][1] = res[n][n] = 1; } int main() { int T; cin >> T; dim = 7; mat C; D p = 1.0 / 6; companion(vector(6, p), C); rep (i_, T) { ll N; cin >> N; matpow(C, N + 4, M3); D s = M3[6][4], t = M3[6][5]; D ans = t / (s - t * 5.0 / 6.0); printf("%.20f\n", (double)ans); } return 0; }