結果

問題 No.58 イカサマなサイコロ
ユーザー DialBirdDialBird
提出日時 2017-02-20 09:30:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,043 ms / 5,000 ms
コード長 864 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 76,368 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 19:32:49
合計ジャッジ時間 12,065 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 418 ms
4,376 KB
testcase_01 AC 2,043 ms
4,376 KB
testcase_02 AC 401 ms
4,376 KB
testcase_03 AC 223 ms
4,376 KB
testcase_04 AC 1,131 ms
4,376 KB
testcase_05 AC 1,320 ms
4,376 KB
testcase_06 AC 1,807 ms
4,376 KB
testcase_07 AC 394 ms
4,380 KB
testcase_08 AC 778 ms
4,380 KB
testcase_09 AC 1,821 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <random>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

int N, K;
int trial = 9000000;

int main(){
  cin >> N >> K;

  int taro_win = 0.0;

  REP(i,0,trial) {
    int taro_result = 0;

    REP(i,0,N){
      if (i < K) {
        taro_result += rand() % 3 + 4;
      } else {
        taro_result += rand() % 6 + 1;
      }
    }

    int jiro_result = 0;

    // 太郎のと一緒にすると、ランダム値が大体一緒になってしまうから
    REP(i,0,N){
      jiro_result += rand() % 6 + 1;
    }

    if (taro_result > jiro_result) ++taro_win;
  }

  printf("%.5f\n", (double)taro_win / trial);
}
0