結果

問題 No.2839 AND Constraint
ユーザー kotatsugamekotatsugame
提出日時 2024-08-09 22:26:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 476 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 67,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-09 22:26:24
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 167 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 476 ms
6,940 KB
testcase_07 AC 457 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 23 ms
6,940 KB
testcase_11 AC 64 ms
6,940 KB
testcase_12 AC 164 ms
6,944 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 79 ms
6,940 KB
testcase_15 AC 35 ms
6,944 KB
testcase_16 AC 181 ms
6,940 KB
testcase_17 AC 40 ms
6,940 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 20 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
mint dp[555][555];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,M;
	cin>>N>>M;
	dp[0][0]=1;
	for(int n=1;n<=N;n++)
	{
		for(int j=0;j<=M;j++)for(int k=0;j+k<=M;k++)
		{
			if(j==0)
			{
				dp[n][j+k]+=dp[n-1][j]*dp[n-1][k];
				dp[n][j+k+1]+=dp[n-1][j]*dp[n-1][k];
			}
			else
			{
				dp[n][j+k+1]+=dp[n-1][j]*dp[n-1][k];
			}
		}
	}
	cout<<dp[N][M].val()<<endl;
}
0