結果

問題 No.2123 Chalk Breaker
ユーザー cutmdocutmdo
提出日時 2023-03-07 16:31:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 982 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 05:32:50
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define PROBLEM "https://yukicoder.me/problems/no/117"

#include <iostream>
#include <iomanip>
#include <vector>

auto Y = [](auto f) {
    return [=](auto&&... args) {
        return f(f, std::forward<decltype(args)>(args)...);
    };
};

using ll = long long;
using std::cout;
using std::cin;
constexpr char endl = '\n';
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;


signed main() {
    ll n;
    cin >> n;

    constexpr double nil = -1.0;
    std::vector<double> dp(n + 1, nil);
    auto f = Y([&](auto&& self, ll n) -> double {
        if(n == 0) { return 0.0; }
        if(dp[n] != nil) { return dp[n]; }

        double ans = 1.0;
        for(int x = 0; x < n; ++x) {
            int y = n - x - 1;
            ans += self(self, x);
            ans += self(self, y);
        }
        ans /= n;
        dp[n] = ans;
        return ans;
    });

    cout << std::fixed << std::setprecision(12) << f(n) << endl;
}
0