結果

問題 No.58 イカサマなサイコロ
ユーザー cielciel
提出日時 2014-11-26 21:14:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 590 ms / 5,000 ms
コード長 555 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 63,432 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-01 22:16:22
合計ジャッジ時間 4,706 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
4,380 KB
testcase_01 AC 590 ms
4,376 KB
testcase_02 AC 120 ms
4,380 KB
testcase_03 AC 62 ms
4,380 KB
testcase_04 AC 354 ms
4,380 KB
testcase_05 AC 420 ms
4,380 KB
testcase_06 AC 532 ms
4,380 KB
testcase_07 AC 120 ms
4,384 KB
testcase_08 AC 240 ms
4,380 KB
testcase_09 AC 542 ms
4,376 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=1000000;
	int S=0;
	uniform_int_distribution<int> gooddice(1,6);
	uniform_int_distribution<int> badddice(4,6);
	mt19937_64 engine((unsigned int)time(NULL)^(getpid()<<16));
	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