結果

問題 No.2123 Chalk Breaker
ユーザー 👑 kakel-sankakel-san
提出日時 2022-11-07 22:08:25
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 67,404 KB
実行使用メモリ 25,796 KB
最終ジャッジ日時 2023-09-28 10:36:32
合計ジャッジ時間 3,661 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
25,796 KB
testcase_01 AC 167 ms
23,932 KB
testcase_02 AC 91 ms
23,548 KB
testcase_03 AC 73 ms
23,848 KB
testcase_04 AC 63 ms
23,728 KB
testcase_05 AC 147 ms
23,900 KB
testcase_06 AC 75 ms
25,764 KB
testcase_07 AC 81 ms
23,608 KB
testcase_08 AC 72 ms
23,580 KB
testcase_09 AC 62 ms
23,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var dp = Enumerable.Repeat(-1.0, n + 1).ToArray();
        dp[0] = 0;
        WriteLine(Break(n, dp));
    }
    static double Break(int n, double[] dp)
    {
        if (dp[n] >= 0) return dp[n];
        var sum = 0.0;
        for (var i = 0; i < n; ++i)
        {
            sum += Break(i, dp) + Break(n - i - 1, dp) + 1;
        }
        dp[n] = sum / n;
        return dp[n];
    }
}
0