結果

問題 No.2137 Stairs of Permutation
ユーザー SSRSSSRS
提出日時 2022-11-25 22:55:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 532 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 1,535 ms
コンパイル使用メモリ 169,036 KB
実行使用メモリ 393,836 KB
最終ジャッジ日時 2024-04-10 04:02:07
合計ジャッジ時間 7,035 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 64 ms
67,780 KB
testcase_03 AC 308 ms
277,040 KB
testcase_04 AC 235 ms
229,992 KB
testcase_05 AC 175 ms
177,432 KB
testcase_06 AC 532 ms
366,660 KB
testcase_07 AC 384 ms
386,556 KB
testcase_08 AC 44 ms
44,148 KB
testcase_09 AC 22 ms
21,724 KB
testcase_10 AC 57 ms
58,392 KB
testcase_11 AC 340 ms
350,056 KB
testcase_12 AC 128 ms
134,052 KB
testcase_13 AC 191 ms
189,224 KB
testcase_14 AC 276 ms
279,968 KB
testcase_15 AC 374 ms
386,748 KB
testcase_16 AC 120 ms
129,080 KB
testcase_17 AC 106 ms
113,440 KB
testcase_18 AC 168 ms
174,636 KB
testcase_19 AC 133 ms
144,884 KB
testcase_20 AC 92 ms
96,216 KB
testcase_21 AC 369 ms
381,448 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 383 ms
393,836 KB
testcase_24 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N;
  cin >> N;
  vector<vector<long long>> dp(4, vector<long long>(N + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 4; j++){
      dp[j][i + 1] += dp[j][i] * (i + 1) % MOD;
      dp[j][i + 1] %= MOD;
      if (j < 3){
        dp[j + 1][i + 1] += dp[j][i];
        dp[j + 1][i + 1] %= MOD;
      }
    }
  }
  cout << (dp[1][N] + dp[2][N] * 6 + dp[3][N] * 6) % MOD << endl;
}
0