結果

問題 No.58 イカサマなサイコロ
ユーザー akakimidoriakakimidori
提出日時 2017-05-07 16:18:36
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 231 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 24,768 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 16:06:34
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
4,348 KB
testcase_01 AC 231 ms
4,352 KB
testcase_02 AC 48 ms
4,348 KB
testcase_03 AC 26 ms
4,348 KB
testcase_04 AC 130 ms
4,352 KB
testcase_05 AC 154 ms
4,352 KB
testcase_06 AC 206 ms
4,352 KB
testcase_07 AC 43 ms
4,352 KB
testcase_08 AC 87 ms
4,352 KB
testcase_09 AC 213 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);

  srand((unsigned)time(NULL));

  const int m=1000000;
  int win=0;
  int i;
  for(i=0;i<m;i++){
    int j;
    int t=0;
    for(j=0;j<n;j++){
      t+=rand()%6;
    }
    int s=0;
    for(j=0;j<n-k;j++){
      s+=rand()%6;
    }
    for(j=0;j<k;j++){
      s+=rand()%3+3;
    }
    win+=(s>t);
  }
  printf("%.4lf\n",(double)win/m);
  return;
}

int main(void){
  run();
  return 0;
}
0