結果

問題 No.58 イカサマなサイコロ
ユーザー finefine
提出日時 2016-10-10 00:33:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,739 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 1,673 ms
コンパイル使用メモリ 166,904 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 18:44:55
合計ジャッジ時間 21,982 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 732 ms
6,812 KB
testcase_01 AC 3,739 ms
6,940 KB
testcase_02 AC 782 ms
6,944 KB
testcase_03 AC 383 ms
6,944 KB
testcase_04 AC 2,254 ms
6,940 KB
testcase_05 AC 2,601 ms
6,944 KB
testcase_06 AC 3,298 ms
6,940 KB
testcase_07 AC 752 ms
6,940 KB
testcase_08 AC 1,460 ms
6,940 KB
testcase_09 AC 3,296 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int TRY = 10000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    srand((unsigned int)time(NULL));
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 0; i < TRY; i++) {
        int taro = 0, jiro = 0;
        for (int j = 0; j < n; j++) jiro += rand() % 6 + 1;
        for (int j = 0; j < n - k; j++) taro += rand() % 6 + 1;
        for (int j = 0; j < k; j++) taro += rand() % 3 + 4;
        if (taro > jiro) cnt += 1;
    }
    cout << cnt * 1.0 / TRY << endl;
    return 0;
}
0