結果

問題 No.76 回数の期待値で練習
ユーザー sugim48sugim48
提出日時 2014-11-23 23:47:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 736 ms / 5,000 ms
コード長 994 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 18,036 KB
最終ジャッジ日時 2023-08-30 22:27:43
合計ジャッジ時間 1,967 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 736 ms
18,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int a[] = {1, 2, 3, 1, 3, 2};

int main() {
	int T; cin >> T;
	while (T--) {
		int N; cin >> N;
		vector<double> dp(N + 1, 1);
		dp[0] = 0;
		for (int i = 1; i <= N; i++)
			for (int j = 1; j <= 6; j++) {
				int _i = max(0, i - j);
				dp[i] += dp[_i] * a[j - 1] / 12;
			}
		printf("%.10f\n", dp[N]);
	}
}
0