class Yukicoder def initialize t, c = gets.chomp.split.map(&:to_i) dp = Hash.new dp[1] = 1.0 t.times do |i| temp = Hash.new dp.each do |k,v| [2,3,5,7,11,13].each do |n| if temp[k*v] temp[k*n] += v * 1/6r else temp[k*n] = v * 1/6r end end end dp = temp.dup end c.times do temp = Hash.new dp.each do |k,v| [4,6,8,9,10,12].each do |n| if temp[k*n] temp[k*n] += v * 1/6r else temp[k*n] = v * 1/6r end end end dp = temp.dup end ans = 0.0 dp.each do |k,v| ans += k * v end puts ans end end Yukicoder.new