結果

問題 No.58 イカサマなサイコロ
ユーザー nemunemunemunemu
提出日時 2024-01-18 07:19:43
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 411 ms / 5,000 ms
コード長 555 bytes
コンパイル時間 1,241 ms
コンパイル使用メモリ 125,340 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-18 07:19:48
合計ジャッジ時間 4,516 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
6,676 KB
testcase_01 AC 411 ms
6,676 KB
testcase_02 AC 83 ms
6,676 KB
testcase_03 AC 43 ms
6,676 KB
testcase_04 AC 247 ms
6,676 KB
testcase_05 AC 292 ms
6,676 KB
testcase_06 AC 367 ms
6,676 KB
testcase_07 AC 88 ms
6,676 KB
testcase_08 AC 168 ms
6,676 KB
testcase_09 AC 368 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.58 イカサマなサイコロ
#include <iostream>
#include <random>
#include <iomanip>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int tot = 0, win = 0;
    for (int iter = 0; iter < 1000000; ++iter) {
        int a = 0, b = 0;
        for (int i = 0; i < N; ++i) a += rand() % 6 + 1;
        for (int i = 0; i < K; ++i) b += rand() % 3 + 4;
        for (int i = 0; i < N - K; ++i) b += rand() % 6 + 1;
        if (b > a) ++win;
        ++tot;
    }

    cout << fixed << setprecision(10) << (double)win / tot << endl;
}
0