def solve k, x dp = Array.new(k + 1, 0.0) (k - 1).downto(0){|i| tmp = 0.0 1.upto(6){|j| if i + j > k tmp += x else tmp += dp[i + j] end } dp[i] = tmp / 6 + 1 } return dp[0] end k = gets.to_i ok = 0 ng = 1e9 100.times{ mid = (ok + ng) / 2 if solve(k, mid) >= mid ok = mid else ng = mid end } p ok