結果

問題 No.1967 Sugoroku Optimization
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-10 22:23:57
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,384 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 64,060 KB
実行使用メモリ 57,788 KB
最終ジャッジ日時 2023-10-10 22:24:04
合計ジャッジ時間 5,737 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,812 KB
testcase_01 AC 60 ms
21,900 KB
testcase_02 AC 60 ms
21,720 KB
testcase_03 AC 193 ms
55,668 KB
testcase_04 AC 64 ms
21,772 KB
testcase_05 AC 179 ms
54,380 KB
testcase_06 AC 187 ms
54,524 KB
testcase_07 AC 64 ms
21,816 KB
testcase_08 AC 154 ms
48,968 KB
testcase_09 AC 129 ms
35,464 KB
testcase_10 AC 95 ms
30,880 KB
testcase_11 AC 68 ms
24,492 KB
testcase_12 AC 145 ms
47,288 KB
testcase_13 AC 103 ms
33,424 KB
testcase_14 AC 66 ms
21,788 KB
testcase_15 AC 65 ms
19,836 KB
testcase_16 AC 67 ms
22,384 KB
testcase_17 AC 65 ms
21,748 KB
testcase_18 AC 62 ms
23,788 KB
testcase_19 AC 61 ms
21,776 KB
testcase_20 AC 193 ms
55,688 KB
testcase_21 AC 60 ms
21,712 KB
testcase_22 AC 193 ms
57,788 KB
testcase_23 AC 143 ms
40,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var mod = 998_244_353;
        var revs = new long[n + 1];
        for (var i = 1; i < revs.Length; ++i) revs[i] = Exp(i, mod - 2, mod);
        var dp = new long[k + 1][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[n + 1];
        dp[0][n] = 1;
        for (var i = 0; i < k; ++i)
        {
            var sum = 0L;
            dp[i + 1][n] = 1;
            for (var j = n - 1; j >= 0; --j)
            {
                sum = (sum + dp[i][j + 1]) % mod;
                dp[i + 1][j] = sum * revs[n - j] % mod;
            }
        }
        WriteLine(dp[k][0]);
    }
    static long Exp(long n, long k, int mod)
    {
        if (k == 0) return 1;
        if (k == 1) return n % mod;
        var half = Exp(n, k / 2, mod);
        var result = (half * half) % mod;
        return ((k % 2) == 0) ? result : ((result * n) % mod);
    }
}
0