結果
| 問題 |
No.2123 Chalk Breaker
|
| ユーザー |
cutmdo
|
| 提出日時 | 2023-03-07 16:35:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 996 bytes |
| コンパイル時間 | 3,206 ms |
| コンパイル使用メモリ | 80,968 KB |
| 最終ジャッジ日時 | 2025-02-11 06:15:46 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#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 sum = 0.0;
for(int x = 0; x < n; ++x) {
int y = n - x - 1;
sum += self(self, x);
sum += self(self, y);
}
auto ans = sum / n + 1;
dp[n] = ans;
return ans;
});
cout << std::fixed << std::setprecision(12) << f(n) << endl;
}
cutmdo