def f(dp,n) dp2=dp.size.times.map{0.0} dp.size.times{|i| break if n<=i if dp[i]>0 (1..6).each{|j| dp2[i+j]+=dp[i]/6.0 } end } return dp2 end es=21.times.map{0.0} (1..20).each{|i| dp=43.times.map{0.0} dp[0]=1.0 ans=0 arr=[] i.times{|k| dp=f(dp,i) dp.size.times{|j| ans+=(k+1)*dp[j] if j>=i } } es[i]=ans } puts es[gets.to_i]