結果
問題 | No.76 回数の期待値で練習 |
ユーザー |
![]() |
提出日時 | 2014-11-24 00:08:50 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 1,311 bytes |
コンパイル時間 | 687 ms |
コンパイル使用メモリ | 84,792 KB |
実行使用メモリ | 11,248 KB |
最終ジャッジ日時 | 2025-01-02 20:52:04 |
合計ジャッジ時間 | 1,331 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 |
ソースコード
#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;double e[7] = {0, 1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235};int main() {vector<double> p(7);for (int j = 1; j <= 5; j++) {double x = e[j + 1] - 1;for (int k = 1; k < j; k++)x -= p[k] * e[j - k + 1];p[j] = x / e[1];}p[6] = 1 - p[1] - p[2] - p[3] - p[4] - p[5];vector<double> dp(1000001, 1);dp[0] = 0;for (int i = 1; i <= 1000000; i++)for (int j = 1; j <= 6; j++) {int _i = max(0, i - j);dp[i] += p[j] * dp[_i];}int T; cin >> T;while (T--) {int N; cin >> N;printf("%.10f\n", dp[N]);}}