結果

問題 No.58 イカサマなサイコロ
ユーザー ldsybldsyb
提出日時 2017-06-22 01:07:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 778 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 87,844 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 10:10:43
合計ジャッジ時間 55,942 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4,951 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 4,951 ms
6,940 KB
testcase_03 AC 4,951 ms
6,944 KB
testcase_04 AC 4,952 ms
6,940 KB
testcase_05 AC 4,951 ms
6,944 KB
testcase_06 AC 4,951 ms
6,940 KB
testcase_07 AC 4,952 ms
6,944 KB
testcase_08 AC 4,951 ms
6,944 KB
testcase_09 AC 4,952 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <random>
#include <chrono>
using namespace std;

int bitcount(int a){
	int r = 0;
	while(a){
		r++;
		a -= a & -a;
	}
	return r;
}

int main(){
	int n, k;
	cin >> n >> k;
	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> rand16(1, 6), rand46(4, 6), randn(0, (1 << n) - 1);
	auto start = chrono::system_clock::now();
	int all = 0, win = 0;
	while(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() < 4950){
		int puni = 0, muni = 0;
		int a = randn(mt);
		while(bitcount(a) != k) a = randn(mt);
		for(int i = 0; i < n; i++) puni += ((a >> i) & 1) ? rand46(mt) : rand16(mt);
		for(int i = 0; i < n; i++) muni += rand16(mt);
		all++;
		if(muni < puni) win++;
	}
	cout << 1. * win / all << endl;
}
0