結果

問題 No.2528 pop_(backfront or not)
ユーザー 👑 chro_96chro_96
提出日時 2023-11-03 23:16:41
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 30,324 KB
実行使用メモリ 64,436 KB
最終ジャッジ日時 2023-11-03 23:16:44
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
64,436 KB
testcase_01 AC 19 ms
64,436 KB
testcase_02 AC 19 ms
64,436 KB
testcase_03 AC 19 ms
64,436 KB
testcase_04 AC 19 ms
64,436 KB
testcase_05 AC 19 ms
64,436 KB
testcase_06 AC 19 ms
64,436 KB
testcase_07 AC 19 ms
64,436 KB
testcase_08 AC 20 ms
64,436 KB
testcase_09 AC 21 ms
64,436 KB
testcase_10 AC 26 ms
64,436 KB
testcase_11 AC 26 ms
64,436 KB
testcase_12 AC 29 ms
64,436 KB
testcase_13 AC 30 ms
64,436 KB
testcase_14 AC 33 ms
64,436 KB
testcase_15 AC 41 ms
64,436 KB
testcase_16 AC 46 ms
64,436 KB
testcase_17 AC 47 ms
64,436 KB
testcase_18 AC 46 ms
64,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  
  int res = 0;
  
  long long dp[2000][4001] = {};
  long long mod_num = 998244353LL;
  
  res = scanf("%d", &n);
  
  dp[0][0] = 0LL;
  dp[0][1] = 1LL;
  dp[0][2] = 0LL;
  for (int i = 1; i < n; i++) {
    dp[i][0] = 0LL;
    dp[i][2*(i+1)] = 0LL;
    for (int j = 1; j < 2*(i+1); j++) {
      dp[i][j] = dp[i-1][j-1]*((long long)((j-1)*(2*(i+1)-j-1)+1));
      dp[i][j] %= mod_num;
      if (j < 2*i) {
        long long cnt = (long long) (((2*i-j)*(2*i-j+1))/2);
        dp[i][j] += dp[i-1][j]*cnt;
        dp[i][j] %= mod_num;
      }
      if (j > 2) {
        long long cnt = (long long) (((j-2)*(j-1))/2);
        dp[i][j] += dp[i-1][j-2]*cnt;
        dp[i][j] %= mod_num;
      }
    }
  }
  
  for (int i = 0; i < 2*n+1; i++) {
    printf("%lld\n", dp[n-1][i]);
  }
  
  return 0;
}
0