結果
| 問題 |
No.3043 括弧列の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 23:13:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 572 bytes |
| コンパイル時間 | 1,864 ms |
| コンパイル使用メモリ | 194,052 KB |
| 実行使用メモリ | 19,812 KB |
| 最終ジャッジ日時 | 2025-02-28 23:13:50 |
| 合計ジャッジ時間 | 3,715 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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[2][0]=1;
for(i=4;i<=n;i++)
{
dp[i][0]=1;
for(j=1;j<=i/2-1;j++)
{
dp[i][j]=(dp[i][j]+2LL*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;
}