require 'prime' class Integer def divisor_list return [] if self <= 0 return [1] if self == 1 prime_division.map{|e| [*(0..e.last)].map{|v| e.first ** v }}.inject{|res, e| res.map{|t| e.map{|v| t * v}}.flatten}.sort end end class Yukicoder def initialize n, p0 = gets.chomp.split(' ').map(&:to_f) n = n.to_i rate = 0.0 2.upto(n) do |num| if num.prime? rate += 1 else rate += (1 - p0) ** (num.divisor_list.size - 2) end end puts rate end end Yukicoder.new