MODE = "stdio" tmp = Array.new if(defined? MODE) tmp = STDIN.read.split("\n") else iotmp = "\ 10 10 -5.0 2.2 4.6 5.0 -1.0 2.0 0.5 0.3 -3.9 1.5 ".split("\n") iotmp.each{|s| tmp << s.strip } end N = tmp[0].to_i B = tmp[1].to_i a = tmp[2].split(" ").map(&:to_f) cnt=0.0 bibun=0 sekibun=0 a.each do |n| bibun += n*B**(n-1) if n==-1.0 sekibun += Math::log(B) else sekibun += 1/(n+1)*B**(n+1) end end printf("%.20f\n", bibun) printf("%.20f\n", sekibun)