結果

問題 No.58 イカサマなサイコロ
ユーザー a5uaa5ua
提出日時 2014-11-05 00:59:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 919 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 61,820 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-29 00:40:35
合計ジャッジ時間 1,159 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main()
{
	const int D_MAX = 6 * 10;
	int N, K;
	cin >> N >> K;
	vector<double> taro(D_MAX + 10, 0.0);
	vector<double> jiro(D_MAX + 10, 0.0);
	taro[0] = 1.0;
	jiro[0] = 1.0;
	for (int i = 0; i < N; ++i) {
		vector<double> taro2(D_MAX + 10, 0.0);
		vector<double> jiro2(D_MAX + 10, 0.0);
		for (int j = 0; j <= D_MAX; ++j) {
			if (i < K) {
				for (int d = 4; d <= 6; ++d) {
					taro2[j + d] += taro[j] / 3;
				}
				for (int d = 1; d <= 6; ++d) {
					jiro2[j + d] += jiro[j] / 6;
				}
			} else {
				for (int d = 1; d <= 6; ++d) {
					taro2[j + d] += taro[j] / 6;
					jiro2[j + d] += jiro[j] / 6;
				}
			}
		}
		swap(taro, taro2);
		swap(jiro, jiro2);
	}
	double ans = 0.0;
	for (int i = 0; i <= D_MAX; ++i) {
		for (int j = 0; j < i; ++j) {
			ans += taro[i] * jiro[j];
		}
	}
	cout << ans << endl;
}
0