結果
問題 | No.3043 括弧列の数え上げ |
ユーザー |
|
提出日時 | 2025-02-28 23:11:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 554 bytes |
コンパイル時間 | 2,130 ms |
コンパイル使用メモリ | 191,812 KB |
実行使用メモリ | 19,680 KB |
最終ジャッジ日時 | 2025-02-28 23:11:51 |
合計ジャッジ時間 | 3,500 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 37 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const ll LLINF=0x3f3f3f3f3f3f3f3fLL;const int mod=998244353;const int MAX=2000+10;int dp[MAX][MAX];int main(){int n,i,j;ll ans;scanf("%d",&n);if(n&1) return 0*puts("0");memset(dp,0,sizeof dp);dp[0][0]=1;for(i=2;i<=n;i++){for(j=0;j<=i/2-1;j++){dp[i][j]=(dp[i][j]+dp[i-2][j])%mod;if(j) dp[i][j]=(dp[i][j]+dp[i-2][j-1])%mod;}}ans=0;for(i=1;i<=n/2-1;i++) ans=(ans+1LL*i*dp[n][i])%mod;printf("%lld\n",ans);return 0;}