結果

問題 No.58 イカサマなサイコロ
ユーザー itezpaceitezpace
提出日時 2017-05-13 23:35:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,865 ms / 5,000 ms
コード長 434 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 52,048 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 16:20:39
合計ジャッジ時間 10,995 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 403 ms
4,352 KB
testcase_01 AC 1,865 ms
4,348 KB
testcase_02 AC 374 ms
4,348 KB
testcase_03 AC 231 ms
4,348 KB
testcase_04 AC 1,042 ms
4,348 KB
testcase_05 AC 1,200 ms
4,352 KB
testcase_06 AC 1,619 ms
4,348 KB
testcase_07 AC 405 ms
4,348 KB
testcase_08 AC 734 ms
4,348 KB
testcase_09 AC 1,592 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int n, k;

bool calc(void) {
  int taro = 0;
  for(int i = 0; i < k; ++i) taro += (rand() % 3 + 4);
  for(int i = 0; i < n - k; ++i) taro += (rand() % 6 + 1);
  int jiro = 0;
  for(int i = 0; i < n; ++i) jiro += (rand() % 6 + 1);
  return taro > jiro;
}

int main() {
  cin>>n>>k;
  double win = 0, test = 8000000;
  for(int i = 0; i < test; ++i) if(calc()) win++;
  cout<<(win/test)<<endl;
}
0