結果

問題 No.58 イカサマなサイコロ
ユーザー nebukuro09nebukuro09
提出日時 2016-10-27 10:27:17
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 4,382 ms / 5,000 ms
コード長 663 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 150,964 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-09-02 22:32:57
合計ジャッジ時間 27,632 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 937 ms
4,368 KB
testcase_01 AC 4,382 ms
4,496 KB
testcase_02 AC 904 ms
4,372 KB
testcase_03 AC 524 ms
4,372 KB
testcase_04 AC 2,655 ms
4,368 KB
testcase_05 AC 3,055 ms
4,372 KB
testcase_06 AC 4,002 ms
4,368 KB
testcase_07 AC 941 ms
4,372 KB
testcase_08 AC 1,756 ms
4,368 KB
testcase_09 AC 3,976 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;

void main() {
  int N = readln().chomp.to!int;
  int K = readln().chomp.to!int;

  auto gen = Random(unpredictableSeed);
  double[] table = new double[](N+1);
  int win = 0;
  foreach (i; iota(10000000)) {
    int taro = 0;
    int jiro = 0;
    foreach (j; iota(N))
      taro += uniform(1, 7, gen);
    foreach (j; iota(N-K))
      jiro += uniform(1, 7, gen);
    foreach (k; iota(K))
      jiro += uniform(4, 7, gen);
    if (jiro > taro)
      win += 1;
  }
  writef("%.04f", to!double(win)/10000000.0);
}
0