結果

問題 No.65 回数の期待値の練習
ユーザー DialBirdDialBird
提出日時 2017-02-18 12:52:23
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 318 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 11,376 KB
実行使用メモリ 15,404 KB
最終ジャッジ日時 2023-08-28 18:50:25
合計ジャッジ時間 2,778 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
15,308 KB
testcase_01 AC 75 ms
15,164 KB
testcase_02 AC 75 ms
15,052 KB
testcase_03 AC 80 ms
15,276 KB
testcase_04 AC 74 ms
15,056 KB
testcase_05 AC 74 ms
15,272 KB
testcase_06 AC 74 ms
15,404 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    @k = gets.to_i
    @dp = Array.new(21, 0)
  end

  def run
    @dp[@k] = 0
    @dp[@k - 1] = 1

    (@k - 2).downto(0) do |i|
      (i + 1).upto(@k - 1) do |j|
        @dp[i] += @dp[j]/6r
      end
      @dp[i] += 1
    end

    return @dp[0].to_f
  end
end

puts Yukicoder.new.run
0