結果

問題 No.553 AlphaCoder Rating
ユーザー maimai
提出日時 2017-08-03 21:06:52
言語 Ruby
(3.3.0)
結果
AC  
実行時間 91 ms / 1,500 ms
コード長 772 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-20 20:54:01
合計ジャッジ時間 1,986 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
12,416 KB
testcase_01 AC 85 ms
12,544 KB
testcase_02 AC 77 ms
12,544 KB
testcase_03 AC 76 ms
12,416 KB
testcase_04 AC 79 ms
12,288 KB
testcase_05 AC 84 ms
12,416 KB
testcase_06 AC 79 ms
12,416 KB
testcase_07 AC 76 ms
12,416 KB
testcase_08 AC 91 ms
12,800 KB
testcase_09 AC 80 ms
12,544 KB
testcase_10 AC 87 ms
12,544 KB
testcase_11 AC 78 ms
12,416 KB
testcase_12 AC 86 ms
12,672 KB
testcase_13 AC 82 ms
12,672 KB
testcase_14 AC 77 ms
12,672 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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 large_f(n)
    return Rational(4649384761075759,20266198323167216) if n == :inf
    Rational(Math.sqrt((0..n).reduce{|s,i| s+0.81r**i}) , (0..n).reduce{|s,i| s+0.9r**i})
end

def small_f(n)
    Rational((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(Rational((0..n).reduce{|s,i| s+g(rperf[i])*(0.9r**i)} , (0..n).reduce{|s,i| s+0.9r**i})) - small_f(n)
end

p rating(n, rperf).round

0