結果
| 問題 |
No.2123 Chalk Breaker
|
| ユーザー |
Tatsu_mr
|
| 提出日時 | 2024-09-30 17:13:56 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 125 ms / 2,000 ms |
| コード長 | 605 bytes |
| コンパイル時間 | 2,982 ms |
| コンパイル使用メモリ | 252,124 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-09-30 17:14:01 |
| 合計ジャッジ時間 | 4,075 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
int main() {
int n;
cin >> n;
vector<ld> dp(n + 1, -1);
auto f = [&](auto f, int x) -> ld {
if (x <= 1) {
return x == 1 ? 1.0 : 0.0;
}
if (dp[x] != -1) {
return dp[x];
}
ld res = 1.0;
for (int y = 0; y < x; y++) {
int a = y, b = x - 1 - y;
ld p = 1.0 / (ld)x;
res += (f(f, a) + f(f, b)) * p;
}
dp[x] = res;
return res;
};
cout << fixed << setprecision(15) << f(f, n) << endl;
}
Tatsu_mr