結果

問題 No.2944 Sigma Partition Problem
ユーザー hitonanode
提出日時 2024-10-18 21:33:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 72 ms / 4,000 ms
コード長 588 bytes
コンパイル時間 1,293 ms
コンパイル使用メモリ 90,828 KB
実行使用メモリ 66,176 KB
最終ジャッジ日時 2024-10-18 22:19:54
合計ジャッジ時間 4,063 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
constexpr int md = 998244353;
constexpr int N = 4010;
using namespace std;

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);

    vector dp(N, vector<int>(N));
    dp.at(0).at(0) = 1;
    for (int v = 1; v < N; ++v) {
        dp[v] = dp[v - 1];
        for (int i = 0; i < N - v; ++i) {
            dp[v][i + v] += dp[v][i];
            if (dp[v][i + v] >= md) dp[v][i + v] -= md;
        }
    }

    int Q;
    cin >> Q;

    while (Q--) {
        int tp, n, k;
        cin >> tp >> n >> k;
        cout << dp[k][n] << '\n';
    }
}
0