def f(k, x) dp = Array.new(k + 1, 0) 1.upto(k) do |i| 1.upto(6) do |j| if j > i dp[i] += x else dp[i] += dp[i - j] end end dp[i] = dp[i] / 6.0 + 1 end dp[k] end def solver(k) ok = k ng = 0 25.times do x = (ok + ng) / 2.0 if f(k, x) <= x ok = x else ng = x end end "%.8f" % ok end T = gets.to_i T.times do n = gets.to_i if n <= 300 puts solver(n) else puts "%.8f" % (5.0 / 3 + n) end end