結果
| 問題 |
No.2944 Sigma Partition Problem
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-10-19 22:05:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 168 ms / 4,000 ms |
| コード長 | 1,161 bytes |
| コンパイル時間 | 2,282 ms |
| コンパイル使用メモリ | 199,956 KB |
| 最終ジャッジ日時 | 2025-02-24 21:44:29 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
vector<vector<mint>> partition(ll n, ll m){
vector res(n+1, vector<mint>(m+1));
res[0][0] = 1;
for (int i=0; i<=n; i++){
for (int j=1; j<=m; j++){
res[i][j] = res[i][j-1];
if (i >= j) res[i][j] += res[i-j][j];
}
}
return res;
}
vector<vector<mint>> partition2(ll n, ll m){
vector res(n+1, vector<mint>(m+1));
res[0][0] = 1;
for (int i=0; i<=n; i++){
for (int j=1; j<=m; j++){
res[i][j] = res[i][j-1];
if (i >= j) res[i][j] += res[i-j][j];
}
}
return res;
}
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
/*
M(i, j) = iの分割で最大値がjのもの
M(i, j) = sum_{k=0}^{i/j} M(i-kj, j-1)
= L(i, j)
*/
int N=4000, M=4000;
vector<vector<mint>> a;
a = partition(N, M);
int Q, t, x, y;
cin >> Q;
while(Q--){
cin >> t >> x >> y;
cout << a[x][y].val() << endl;
}
return 0;
}
srjywrdnprkt