結果
| 問題 |
No.2944 Sigma Partition Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-18 22:56:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,494 bytes |
| コンパイル時間 | 2,187 ms |
| コンパイル使用メモリ | 200,148 KB |
| 最終ジャッジ日時 | 2025-02-24 21:07:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 23 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using ll=long long;
using mint=atcoder::modint998244353;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
const int MAX=4000;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
// M(n,k)
vector M(MAX+1,vector<mint>(MAX+1));
M[0][0]=1;
for(int i=1;i<=MAX;i++)for(int j=1;j<=MAX;j++){
M[i][j]+=M[i-1][j-1];
if(i-j>=0)M[i][j]+=M[i-j][j];
}
vector SM(MAX+1,vector<mint>(MAX+1));
for(int i=0;i<=MAX;i++){
SM[i][0]=M[i][0];
for(int j=1;j<=MAX;j++){
SM[i][j]=SM[i][j-1]+M[i][j];
}
}
// L(n,k)
vector L(MAX+1,vector<mint>(MAX+1));
L[0][0]=1;
for(int i=1;i<=MAX;i++)for(int j=1;j<=MAX;j++){
L[i][j]+=L[i-1][j-1];
if(i-j>=0)L[i][j]+=L[i-j][j];
}
vector SL(MAX+1,vector<mint>(MAX+1));
for(int i=0;i<=MAX;i++){
SL[i][0]=L[i][0];
for(int j=1;j<=MAX;j++){
SL[i][j]=SL[i][j-1]+L[i][j];
}
}
int Q;
cin>>Q;
while(Q--){
int t;
ll n,k;
cin>>t>>n>>k;
if(k>n){
cout<<0<<"\n";
}else{
if(t==1)cout<<SM[n][k].val()<<"\n";
else cout<<SL[n][k].val()<<"\n";
}
}
}