#!/usr/local/bin/ruby class FakeDice def initialize(*arg) @n,@k = arg @jirodice = normal_dice_pb(@n) @tarodice = fake_dice_pb(@k,normal_dice_pb(@n-@k)) end private def normal_dice_pb(n) dp = Hash.new(0) dp[0]=1 n.times do newdp = Hash.new(0) dp.each do |dsum,pb| (1..6).each do |i| newdp[dsum+i] += pb/6.to_r end end dp = newdp end dp end def fake_dice_pb(k,dp) k.times do newdp = Hash.new(0) dp.each do |dsum,pb| (4..6).each do |i| newdp[dsum+i] += pb/3.to_r end end dp = newdp end dp end public def ans cumsum = Array.new(@n*6+2,0) d = @n*6 while d >= @n+1 cumsum[d] = cumsum[d+1] + @tarodice[d] d-=1 end r = 0 d =@n while d < @n*6 r += @jirodice[d]*cumsum[d+1] d+=1 end r.to_f end end ### END: class FakeDice iod = STDIN n = iod.gets.to_i k = iod.gets.to_i puts FakeDice.new(n,k).ans exit 0