結果

問題 No.58 イカサマなサイコロ
ユーザー kaiyori_labkaiyori_lab
提出日時 2014-11-05 00:50:50
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 2,003 ms / 5,000 ms
コード長 567 bytes
コンパイル時間 6,074 ms
コンパイル使用メモリ 149,180 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 19:04:54
合計ジャッジ時間 18,066 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 425 ms
4,368 KB
testcase_01 AC 2,003 ms
4,368 KB
testcase_02 AC 418 ms
4,368 KB
testcase_03 AC 222 ms
4,368 KB
testcase_04 AC 1,238 ms
4,368 KB
testcase_05 AC 1,439 ms
4,372 KB
testcase_06 AC 1,829 ms
4,368 KB
testcase_07 AC 418 ms
4,368 KB
testcase_08 AC 824 ms
4,368 KB
testcase_09 AC 1,847 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.conv;
import std.random;
import std.algorithm;

int taro(int n, int k){
	int arr;
	foreach(i; 0..k){ arr += [4, 4, 5, 5, 6, 6][uniform(0, 6)]; }
	foreach(i; k..n){ arr += [1, 2, 3, 4, 5, 6][uniform(0, 6)]; }
	return arr;
}

int jiro(int n){
	int arr;
	foreach(i; 0..n){ arr += [1, 2, 3, 4, 5, 6][uniform(0, 6)]; }
	return arr;
}

void main(){
	int n, k; readf("%d\n%d", &n, &k);
	int win = 0;
	int times = 1000000;
	foreach(t; 0..times){
		if(taro(n, k) > jiro(n)) win++;
	}
	writeln(cast(real) win/times);
}

0