import std.conv, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken().to!int; } long readLong() { return readToken().to!long; } real readReal() { return readToken().to!real; } void chmin(T)(ref T t, in T f) { if (t > f) t = f; } void chmax(T)(ref T t, in T f) { if (t < f) t = f; } int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; } int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); } int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); } alias P = Tuple!(real[], real); P multiply(P a, P b) { P ret = tuple(new real[11], 0.0); ret[0][] = 0.0; foreach (i; 0 .. 6) foreach (j; 0 .. 6) { ret[0][i + j] += a[0][i] * b[0][j]; } ret[1] = a[0].sum * b[1] + a[1]; foreach_reverse (i; 6 .. 11) { foreach (j; 1 .. 7) { ret[0][i - j] += ret[0][i] / 6.0; } ret[1] += ret[0][i]; } ret[0].length = 6; return ret; } long N; void main() { enum LIM = 10^^5; auto x = new real[LIM]; auto y = new real[LIM]; x[] = 0.0; y[] = 0.0; foreach (i; 1 .. LIM) { x[i] += 1.0; foreach (j; 1 .. 7) { if (i - j >= 0) { x[i] += x[i - j] / 6.0; y[i] += y[i - j] / 6.0; } else { y[i] += 1.0 / 6.0; } } } try { for (; ; ) { const T = readInt(); foreach (caseId; 0 .. T) { N = readLong(); /* P a = tuple(new real[6], 0.0); a[0][] = 0.0; a[0][0] = 1.0; foreach_reverse (h; 0 .. bsr(N) + 1) { a = multiply(a, a); if ((N >> h) & 1) { a[0] = 0.0 ~ a[0]; foreach (i; 0 .. 6) { a[0][i] += a[0][6] / 6.0; } a[1] += a[0][6]; a[0].length = 6; } } debug { writeln(a); } real xx = a[1], yy = 0.0; foreach (i; 0 .. 6) { xx += a[0][i] * x[i]; yy += a[0][i] * y[i]; } debug { writefln("%.20f %.20f", xx, yy); } const ans = xx / (1.0 - yy); */ real ans; if (N >= LIM) { ans = N + 5.0 / 3.0; } else { ans = x[cast(size_t)(N)] / (1.0 - y[cast(size_t)(N)]); } writefln("%.20f", ans); } } } catch (EOFException e) { } }