line = gets.chomp! abort "format error" unless line=~/^\d+$/ n = line.to_i abort "1<=n<=100" unless 1<=n && n<=100 rperf = [nil] n.times{ line = gets.chomp! abort "format error" unless line=~/^\d+$/ rperf << line.to_r } abort "EOF" unless !gets # 等比数列の和 def sum_seq(a, r, n) a*(1.0-r**n) / (1.0-r) end def large_f(n) n=10000 if n == :inf Math.sqrt(sum_seq(0.81,0.81,n)) / sum_seq(0.9,0.9,n) end def small_f(n) ((large_f(n)-large_f(:inf)) / (large_f(1)-large_f(:inf)))*1200 end def g(x) 2.0**(x/800.0) end def g_inv(y) 800.0*Math.log2(y) end def rating(n, rperf) g_inv((0..n).reduce{|s,i| s+g(rperf[i])*(0.9**i)} / sum_seq(0.9,0.9,n)) - small_f(n) end p rating(n, rperf).round + 0