結果
| 問題 | No.76 回数の期待値で練習 |
| コンテスト | |
| ユーザー |
not_522
|
| 提出日時 | 2015-08-20 02:34:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 5,000 ms |
| コード長 | 647 bytes |
| コンパイル時間 | 1,118 ms |
| コンパイル使用メモリ | 163,376 KB |
| 実行使用メモリ | 17,488 KB |
| 最終ジャッジ日時 | 2024-07-18 10:46:47 |
| 合計ジャッジ時間 | 1,562 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<double> p(7), v{0, 1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235};
for (int i = 1; i <= 5; ++i) {
p[i] = v[i + 1] - 1;
for (int j = 1; j < i; ++j) p[i] -= p[j] * v[i - j + 1];
}
p[6] = 1 - accumulate(p.begin(), p.end() - 1, 0.);
for (int i = 7; i <= 1000000; ++i) {
v.emplace_back(inner_product(p.begin() + 1, p.end(), v.rbegin(), 0.) + 1);
}
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n;
cin >> n;
cout << fixed << setprecision(15) << v[n] << endl;
}
}
not_522