結果

問題 No.75 回数の期待値の問題
ユーザー letrangerjpletrangerjp
提出日時 2017-10-21 15:47:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 3,634 ms / 5,000 ms
コード長 222 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 15,416 KB
最終ジャッジ日時 2023-08-13 16:27:41
合計ジャッジ時間 18,167 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
15,272 KB
testcase_01 AC 258 ms
15,388 KB
testcase_02 AC 249 ms
15,328 KB
testcase_03 AC 316 ms
15,368 KB
testcase_04 AC 245 ms
15,392 KB
testcase_05 AC 242 ms
15,384 KB
testcase_06 AC 240 ms
15,196 KB
testcase_07 AC 323 ms
15,180 KB
testcase_08 AC 330 ms
15,028 KB
testcase_09 AC 340 ms
15,240 KB
testcase_10 AC 355 ms
15,328 KB
testcase_11 AC 375 ms
15,412 KB
testcase_12 AC 405 ms
15,416 KB
testcase_13 AC 416 ms
15,164 KB
testcase_14 AC 431 ms
15,264 KB
testcase_15 AC 518 ms
15,192 KB
testcase_16 AC 1,650 ms
15,240 KB
testcase_17 AC 2,853 ms
15,248 KB
testcase_18 AC 3,402 ms
15,148 KB
testcase_19 AC 3,634 ms
15,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

K = gets.to_i
N = 100000
total_count = 0
N.times{
  count = 0
  loop {
    sum = 0
    while sum < K
      sum += rand(1..6)
      count += 1
    end
    break if sum == K
  }
  total_count += count
}
p total_count.fdiv N
0