結果

問題 No.58 イカサマなサイコロ
ユーザー face4face4
提出日時 2018-06-03 14:08:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 545 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 69,560 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 21:51:33
合計ジャッジ時間 1,813 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
4,380 KB
testcase_01 AC 116 ms
4,380 KB
testcase_02 AC 24 ms
4,380 KB
testcase_03 AC 13 ms
4,376 KB
testcase_04 AC 66 ms
4,376 KB
testcase_05 AC 77 ms
4,380 KB
testcase_06 AC 102 ms
4,376 KB
testcase_07 AC 23 ms
4,380 KB
testcase_08 AC 44 ms
4,380 KB
testcase_09 AC 104 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;

    int total = 0, win = 0;
    for(int i = 0; i < 500000; i++){
        int taro = 0, ziro = 0;
        
        for(int j = 0; j < n-k; j++)    taro += rand()%6 + 1;
        for(int j = 0; j < n; j++)      ziro += rand()%6 + 1;
        for(int j = 0; j < k; j++)      taro += rand()%3 + 4;        

        if(taro > ziro) win++;
        total++;
    }

    cout << fixed << setprecision(9) << (double)win / total << endl;
    return 0;
}
0