AT_arc232_e.Doubling
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a sequence of non-negative integers of length N+1, X=(X1,X2,…,XN+1), where XN+1=0.
You can perform the following operation.
- Choose an integer i satisfying 1≤i≤N and Xi≥1, subtract 1 from Xi, and add 2 to Xi+1.
You are given an integer K. For each k=1,2,…,K, find the number, modulo 998244353, of sequences that can result from performing the operation exactly k times on the given sequence.
给你一个长度为 N+1 的非负整数序列 X=(X1,X2,…,XN+1),其中 XN+1=0。
你可以执行以下操作:
- 选择一个满足 1≤i≤N 且 Xi≥1 的整数 i,将 Xi 减 1,并将 Xi+1 加 2。
给定一个整数 K。对每个 k=1,2,…,K,求在给定序列上恰好执行 k 次该操作后所能得到的不同序列的个数(对 998244353 取模)。
输入格式
The input is given from Standard Input in the following format. XN+1 is not included in the input.
N K
X1 X2 … XN
输入从标准输入给出,格式如下。XN+1 不包含在输入中。
N K
X1 X2 … XN
输出格式
Output the answers for k=1,2,⋯,K in this order, separated by spaces, on a single line.
按顺序输出 k=1,2,⋯,K 对应的答案,答案之间用空格分隔,放在一行中。
输入输出样例
输入#1
2 5 1 1
输出#1
2 1 1 1 0
输入#2
2 4 1 0
输出#2
1 1 1 0
输入#3
1 1 0
输出#3
0
输入#4
3 4 0 0 2
输出#4
1 1 0 0
输入#5
4 7 1 0 1 0
输出#5
2 3 4 4 5 5 5
说明/提示
Sample 1 Explanation:
The sequences that can result from performing the operation once are (0,3,0) and (1,0,2), so there are two of them. The only sequence that can result from performing the operation twice is (0,2,2), so there is one. Multiple orders of operations yield this sequence, but it is counted as one sequence.
Sample 2 Explanation:
The initial sequence is (1,0,0). With each operation, the sequence changes to (0,2,0), (0,1,2), (0,0,4). The operation cannot be performed four times.
Constraints
- 1≤N≤20
- 1≤K≤250000
- 0≤Xi≤250000 (1≤i≤N)
- XN+1=0
- All input values are integers.
样例 1 解释:
执行一次操作后可能得到的序列为 (0,3,0) 和 (1,0,2),共两个。执行两次操作后唯一可能得到的序列为 (0,2,2),仅一个。尽管存在多种操作顺序可得到该序列,但它仅被计为一个序列。
样例 2 解释:
初始序列为 (1,0,0)。每次执行操作后,序列依次变为 (0,2,0)、(0,1,2)、(0,0,4)。无法执行四次操作。
约束条件
- 1≤N≤20
- 1≤K≤250000
- 0≤Xi≤250000 (1≤i≤N)
- XN+1=0
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?