結果

問題 No.58 イカサマなサイコロ
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-23 03:04:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 906 ms / 5,000 ms
コード長 690 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 61,312 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 03:30:00
合計ジャッジ時間 6,309 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
4,380 KB
testcase_01 AC 906 ms
4,376 KB
testcase_02 AC 171 ms
4,376 KB
testcase_03 AC 91 ms
4,376 KB
testcase_04 AC 499 ms
4,376 KB
testcase_05 AC 575 ms
4,376 KB
testcase_06 AC 788 ms
4,384 KB
testcase_07 AC 173 ms
4,376 KB
testcase_08 AC 334 ms
4,376 KB
testcase_09 AC 789 ms
4,376 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