#P16810. [蓝桥杯 2026 国 Python A] 亮灭反转

    ID: 19151 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>动态规划 DP2026蓝桥杯国赛

[蓝桥杯 2026 国 Python A] 亮灭反转

Problem Description

In front of Xiao Lan, there are nn lamps in a row. Each lamp is initially either on or off. Therefore, there are 2n2^n different initial states in total.

For a certain initial state, Xiao Lan will make n+1n + 1 independent observations. Each observation starts directly from the same initial state (the observations do not affect each other):

  • Observation 00: Do not change the state of any lamp, and record the number of lamps that are on in the whole row at this time.
  • Observation kk (1kn1 \le k \le n): Based on the initial state, first flip the states of the first kk lamps (on becomes off, off becomes on), then record the number of lamps that are on in the whole row at this time.

Let the numbers of lamps that are on obtained in these n+1n + 1 observations be b0,b1,,bnb_0, b_1, \ldots, b_n in order. If, in the sequence b0,b1,,bnb_0, b_1, \ldots, b_n, the number of distinct elements is exactly mm, then this initial state is called good.

Now, please help Xiao Lan compute how many good initial states there are in total. Since the answer may be very large, you only need to output the result modulo 998244353998244353.

Input Format

Input one line containing two integers nn and mm, separated by a single space.

Output Format

Output one integer, representing the number of valid initial states modulo 998244353998244353.

3 2
2

Hint

Sample Explanation

When n=3,m=2n = 3, m = 2, there are 22 valid initial states that meet the requirement, namely “off, on, off” and “on, off, on”:

If the initial state is “off, on, off”, then the sequence bb of numbers of lamps that are on after each observation is [1,2,1,2][1, 2, 1, 2]. The distinct elements are 11 and 22, so there are 22 kinds.

If the initial state is “on, off, on”, then the sequence bb is [2,1,2,1][2, 1, 2, 1]. The distinct elements are 22 and 11, so there are 22 kinds.

It can be verified that only these 22 initial states satisfy the condition that the number of distinct elements is exactly 22.

Constraints

For 30%30\% of the testdata, 1n201 \le n \le 20.

For 60%60\% of the testdata, 1n30001 \le n \le 3000, 1m451 \le m \le 45.

For all testdata, 1n2×1051 \le n \le 2 \times 10^5, 1m451 \le m \le 45.

Translated by ChatGPT 5