結果

問題 No.75 回数の期待値の問題
ユーザー fine
提出日時 2016-12-29 19:35:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 458 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 165,796 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-15 07:57:42
合計ジャッジ時間 2,552 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

double dp[205];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K;
	cin >> K;
	dp[0] = 300;
	double ans = dp[0];
	for (int loop = 0; loop < 10000; loop++) {		
		for (int i = K - 1; i >= 0; i--) {
			dp[i] = 0.0;
			for (int j = 1; j <= 6; j++) {
				if (i + j > K) dp[i] += ans;
				else dp[i] += dp[i + j];
			}
			dp[i] /= 6;
			dp[i]++;
		}
		ans = dp[0];
	}
	cout << ans << endl;
	return 0;
}
0