#P16809. [蓝桥杯 2026 国 Python A] 前缀奇偶

    ID: 19150 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>组合数学2026蓝桥杯国赛

[蓝桥杯 2026 国 Python A] 前缀奇偶

Problem Description

Xiao Lan has nn tasks in hand. The time costs of the tasks are all different: 11 minute, 22 minutes, ⋯\cdots, nn minutes.

Xiao Lan needs to choose an order to complete these tasks one by one. Each time he finishes a task, he records the total accumulated time from the start up to the current moment.

Suppose that in some execution order, the task times are a1,a2,…,ana_1, a_2, \ldots, a_n. Then when finishing the ii-th task, the recorded accumulated total time is:

$$\begin{aligned} S_i = a_1 + a_2 + \dots + a_i \end{aligned}$$

If among the nn recorded times S1,S2,…,SnS_1, S_2, \ldots, S_n, exactly kk of them are even, then this execution order is considered valid.

Now please help Xiao Lan compute how many different execution orders are valid 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 n,kn, k.

Output Format

Output one integer, representing the answer.

3 1
2

Hint

Sample Explanation

When n=3,k=1n = 3, k = 1, the valid execution orders are:

1,2,3\begin{aligned} 1, 2, 3 \end{aligned}

and

3,2,1\begin{aligned} 3, 2, 1 \end{aligned}

Take the order 1,2,31, 2, 3 as an example. The three completion times are 1,3,61, 3, 6, and only 66 is even.

Constraints and Notes for Test Cases

For 30%30\% of the test cases, 1≤n≤101 \le n \le 10.

For 60%60\% of the test cases, 1≤n≤50001 \le n \le 5000.

For all test cases, 1≤n≤1061 \le n \le 10^6, 0≤k≤n0 \le k \le n.

Translated by ChatGPT 5