結果

問題 No.58 イカサマなサイコロ
ユーザー satanicsatanic
提出日時 2016-03-29 16:51:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,069 ms / 5,000 ms
コード長 837 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 84,036 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 05:51:00
合計ジャッジ時間 12,551 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 433 ms
6,812 KB
testcase_01 AC 2,069 ms
6,944 KB
testcase_02 AC 433 ms
6,940 KB
testcase_03 AC 226 ms
6,944 KB
testcase_04 AC 1,253 ms
6,944 KB
testcase_05 AC 1,461 ms
6,944 KB
testcase_06 AC 1,868 ms
6,940 KB
testcase_07 AC 430 ms
6,948 KB
testcase_08 AC 841 ms
6,948 KB
testcase_09 AC 1,871 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <random>
#include <iomanip>

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    std::random_device seed_gen;
    std::mt19937 engine(seed_gen());
    int n, k;
    std::cin >> n >> k;
    int scoreTaro = 0;
    int scoreJiro = 0;
    int winTaro = 0;
    const int battleNum = 10000000;
    for(int i=0; i<battleNum; ++i){
        scoreTaro = scoreJiro = 0;
        for(int j=0; j<n-k; ++j){
            scoreTaro += engine()%6+1;
        }
        for(int j=0; j<k; ++j){
            scoreTaro += engine()%3+4;
        }
        for(int j=0; j<n; ++j){
            scoreJiro += engine()%6+1;
        }
        if(scoreTaro > scoreJiro){
            ++winTaro;
        }
    }
    std::cout << std::fixed << std::setprecision(6) << winTaro*1.0/battleNum << "\n";

    return 0;
}
0