結果

問題 No.2123 Chalk Breaker
ユーザー Tatsu_mr
提出日時 2024-09-30 17:09:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 649 bytes
コンパイル時間 2,785 ms
コンパイル使用メモリ 250,792 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-09-30 17:09:11
合計ジャッジ時間 3,978 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 = 0.0;
        for (int y = 0; y < x; y++) {
            int a = y, b = x - 1 - y;
            ld p1 = 1.0 / 2.0;
            ld p2 = 1.0 / (ld)x;
            res += (f(f, a) + f(f, b)) * p1 * p2 + 1.0;
        }
        dp[x] = res;
        return res;
    };
    cout << fixed << setprecision(15) << f(f, n) << endl;
}
0