#include #include #include #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) #define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i)) typedef long long ll; using namespace std; template using matrix = array,H>; template matrix operator * (matrix const & p, matrix const & q) { matrix r = {}; repeat (y,A) { repeat (z,B) { repeat (x,C) { r[y][x] += p[y][z] * q[z][x]; } } } return r; } template array operator * (matrix const & p, array const & q) { array r = {}; repeat (y,A) { repeat (z,B) { r[y] += p[y][z] * q[z]; } } return r; } template matrix matrix_zero() { return {}; } template matrix matrix_unit() { matrix a = {}; repeat (i,N) a[i][i] = 1; return a; } int main() { array ax = { 0, 0, 0, 0, 0, 0, 1 }; array bx = { 1, 0, 0, 0, 0, 0 }; vector,7> > aes; vector,6> > bes; { array,7> ae { 1./6, 1./6, 1./6, 1./6, 1./6, 1./6, 1 , 1, 0, 0, 0, 0, 0, 0 , 0, 1, 0, 0, 0, 0, 0 , 0, 0, 1, 0, 0, 0, 0 , 0, 0, 0, 1, 0, 0, 0 , 0, 0, 0, 0, 1, 0, 0 , 0, 0, 0, 0, 0, 0, 1 }; array,6> be { 1./6, 1./6, 1./6, 1./6, 1./6, 1./6 , 1, 0, 0, 0, 0, 0 , 0, 1, 0, 0, 0, 0 , 0, 0, 1, 0, 0, 0 , 0, 0, 0, 1, 0, 0 , 0, 0, 0, 0, 1, 0 }; repeat (i,64) { aes.push_back(ae); bes.push_back(be); ae = ae * ae; be = be * be; } } int t; scanf("%d", &t); while (t --) { ll n; scanf("%lld", &n); array,7> af = matrix_unit(); array,6> bf = matrix_unit(); repeat (i,64) if (n & (1ll << i)) { af = af * aes[i]; bf = bf * bes[i]; } long double a = (af * ax)[0]; long double b = (bf * bx)[0]; long double ans = a / b; printf("%.18llf\n", ans); } return 0; }