結果

問題 No.58 イカサマなサイコロ
ユーザー letrangerjpletrangerjp
提出日時 2017-06-17 19:09:07
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 3,773 ms / 5,000 ms
コード長 571 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 30,208 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 11:28:58
合計ジャッジ時間 21,280 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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