結果

問題 No.65 回数の期待値の練習
コンテスト
ユーザー ふう
提出日時 2015-01-26 11:27:53
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 532 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 673 ms
コンパイル使用メモリ 105,864 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-07 17:25:11
合計ジャッジ時間 1,452 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>

using namespace std;

double e(int x, int k)
{
	double res = 0;

	if (x >= k) return (0);

	for (int i = 1; i <= 6; i++) {
		res += e(x + i, k) / 6;
	}
	
	return (res + 1);
}

int main(void)
{
	int k;

	cin >> k;

	cout << e(0, k) << endl;

	return (0);
}
0