結果

問題 No.2839 AND Constraint
ユーザー tomeruntomerun
提出日時 2024-08-09 22:20:35
言語 Crystal
(1.11.2)
結果
AC  
実行時間 397 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 12,313 ms
コンパイル使用メモリ 295,124 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-08-09 22:20:52
合計ジャッジ時間 14,618 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 129 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 397 ms
5,376 KB
testcase_07 AC 367 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 19 ms
5,376 KB
testcase_11 AC 53 ms
5,376 KB
testcase_12 AC 135 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 62 ms
5,376 KB
testcase_15 AC 28 ms
5,376 KB
testcase_16 AC 136 ms
5,376 KB
testcase_17 AC 32 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 17 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353i64
n, m = read_line.split.map(&.to_i)
if n <= 10 && (1 << n) - 1 < m
  puts 0
  exit
end
dp = Array.new(n) { Array.new(m + 1, 0i64) }
dp[0][0] = 1
dp[0][1] = 1
1.upto(n - 1) do |i|
  0.upto(m) do |j|
    dp[i][j] += dp[i - 1][j]
    dp[i][j] %= MOD
    if j < m
      dp[i][j + 1] += dp[i - 1][j]
      dp[i][j + 1] %= MOD
    end
    1.upto(m - j - 1) do |k|
      dp[i][j + k + 1] += dp[i - 1][j] * dp[i - 1][k]
      dp[i][j + k + 1] %= MOD
    end
  end
end
puts dp[n - 1][m]
0