結果

問題 No.1492 01文字列と転倒
ユーザー rtyu
提出日時 2021-10-19 14:09:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,087 ms / 4,000 ms
コード長 559 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 67,848 KB
実行使用メモリ 19,768 KB
最終ジャッジ日時 2024-09-20 06:21:24
合計ジャッジ時間 10,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

long long d[2][109][10009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; long long md; cin >> n >> md;
	d[0][0][0] = 1;
	for (int i = 1; i <= 2 * n; i++)
		for (int j = 0; j <= i / 2; j++)
			for (int k = 0; k <= n * n; k++) {
				if (k >= j) d[(i & 1)][j][k] = d[!(i & 1)][j][k - j];
				else d[(i & 1)][j][k] = 0;
				if (j) d[(i & 1)][j][k] = (d[(i & 1)][j][k] + d[!(i & 1)][j - 1][k]) % md;
			}
	for (int i = 0; i <= n * n; i++)
		cout << d[0][n][i] << '\n';
	return 0;
}
0