結果

問題 No.58 イカサマなサイコロ
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-23 03:04:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,619 ms / 5,000 ms
コード長 690 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 59,300 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 20:32:45
合計ジャッジ時間 10,103 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 338 ms
6,816 KB
testcase_01 AC 1,619 ms
6,944 KB
testcase_02 AC 340 ms
6,940 KB
testcase_03 AC 177 ms
6,940 KB
testcase_04 AC 980 ms
6,940 KB
testcase_05 AC 1,142 ms
6,940 KB
testcase_06 AC 1,466 ms
6,944 KB
testcase_07 AC 330 ms
6,944 KB
testcase_08 AC 666 ms
6,944 KB
testcase_09 AC 1,468 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int n, k;

bool solve(){//モンテカルロ法

    int sum_taro = 0;
    rep(i, k){
        sum_taro += rand() % 3 + 4;
    }
    rep(i, n - k){
        sum_taro += rand() % 6 + 1;
    }

    int sum_ziro = 0;
    rep(i, n){
        sum_ziro += rand() % 6 + 1;
    }

    if(sum_taro > sum_ziro) return true;
    else return false;
}

int main(void){
    cin >> n >> k;
    
    int win = 0;
    rep(i, 4000000){
        if(solve()) win++;
    }
    printf("%.9f\n", (double)win / 4000000.0);
    return 0;
}
0