結果

問題 No.58 イカサマなサイコロ
ユーザー letrangerjpletrangerjp
提出日時 2017-06-17 19:09:07
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 4,023 ms / 5,000 ms
コード長 571 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 20:32:27
合計ジャッジ時間 22,318 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 808 ms
6,676 KB
testcase_01 AC 4,023 ms
6,676 KB
testcase_02 AC 803 ms
6,676 KB
testcase_03 AC 406 ms
6,676 KB
testcase_04 AC 2,411 ms
6,676 KB
testcase_05 AC 2,814 ms
6,676 KB
testcase_06 AC 3,618 ms
6,676 KB
testcase_07 AC 809 ms
6,676 KB
testcase_08 AC 1,611 ms
6,676 KB
testcase_09 AC 3,593 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

const int M = 1e7L;

// eval"p (1..1e6).count{(1..%d).map{|i|rand(6)-rand(i>%d?6:3..5)}.sum<0}/1e6"%[*$<]
int main(void)
{
  int N, K;
  scanf("%d\n", &N);
  scanf("%d\n", &K);
  srand(time(NULL));

  int count = 0;
  for (int i = 0; i < M; ++i) {
    int taro = 0, jiro = 0;
    for (int j = 0; j < N; ++j) {
      if (j < K)
        taro += 4 + rand()%3;
      else
        taro += 1 + rand()%6;
      jiro += 1 + rand()%6;
    }
    if (taro > jiro)
      ++count;
  }
  printf("%f\n", ((double)count) / M);
}
0