#include #include #include #include #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) #define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i)) using namespace std; int main() { // input int q; scanf("%d", &q); map > f; repeat (i,q) { int n; scanf("%d", &n); f[n].push_back(i); } // compute vector ans(q); array e = { 0, 1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235 }; array p = {}; p[0] = e[2] - 1; p[1] = e[3] - p[0]*e[2] - 1; p[2] = e[4] - p[0]*e[3] - p[1]*e[2] - 1; p[3] = e[5] - p[0]*e[4] - p[1]*e[3] - p[2]*e[2] - 1; p[4] = e[6] - p[0]*e[5] - p[1]*e[4] - p[2]*e[3] - p[3]*e[2] - 1; p[5] = 1 - p[0] - p[1] - p[2] - p[3] - p[4]; int limit = f.rbegin()->first + 1; repeat (i,limit) { if (i > 6) { e[i%7] = 1; repeat (j,6) { e[i%7] += p[j] * e[(i-j-1 +7)%7]; } } if (f.count(i)) for (int j : f[i]) { ans[j] = e[i%7]; } } // output repeat (i,q) { printf("%.16lf\n", ans[i]); } return 0; }