結果

問題 No.58 イカサマなサイコロ
ユーザー cielciel
提出日時 2015-06-19 03:43:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 597 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 63,632 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 09:39:42
合計ジャッジ時間 4,516 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
4,376 KB
testcase_01 AC 597 ms
4,380 KB
testcase_02 AC 123 ms
4,384 KB
testcase_03 AC 63 ms
4,380 KB
testcase_04 AC 361 ms
4,376 KB
testcase_05 AC 421 ms
4,376 KB
testcase_06 AC 539 ms
4,380 KB
testcase_07 AC 122 ms
4,384 KB
testcase_08 AC 241 ms
4,380 KB
testcase_09 AC 543 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <random>
#include <cstdio>
#include <ctime>
#include <unistd.h>
using namespace std;

int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    int T=999999;
    int S=0;
    uniform_int_distribution<int> gooddice(1,6);
    uniform_int_distribution<int> badddice(4,6);
    mt19937_64 engine(0);
    for(int I=0;I<T;I++){
        int a=0,b=0,i=0;
        for(;i<K;i++)a+=gooddice(engine),b+=badddice(engine);
        for(;i<N;i++)a+=gooddice(engine),b+=gooddice(engine);
        if(a<b)S++;
    }
    printf("%f\n",S*1.0/T);
}
0