#abc370e. E - Avoid K Partition
E - Avoid K Partition
Score : points
问题陈述
给定一个长度为 的序列 和一个整数 。 将 分割成几个连续子序列有 种方式。有多少种分割方式使得没有子序列的元素之和等于 ?求出这个数量对 取模的结果。
这里,“将 分割成几个连续子序列”意味着以下过程:
- 自由选择子序列的数量 和一个整数序列 ,满足 。
- 对于每个 ,第 个子序列由取 中第 个到第 个元素组成,保持它们的顺序。
以下是 的一些分割示例:
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a sequence of length and an integer .
There are ways to divide into several contiguous subsequences. How many of these divisions have no subsequence whose elements sum to ? Find the count modulo .
Here, "to divide into several contiguous subsequences" means the following procedure.
- Freely choose the number of subsequences and an integer sequence satisfying $1 = i_1 \lt i_2 \lt \dots \lt i_k \lt i_{k+1} = N+1$.
- For each , the -th subsequence is formed by taking the -th through -th elements of , maintaining their order.
Here are some examples of divisions for :
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the count modulo .
Sample Input 1
3 3
1 2 3
Sample Output 1
2
There are two divisions that satisfy the condition in the problem statement:
Sample Input 2
5 0
0 0 0 0 0
Sample Output 2
0
Sample Input 3
10 5
-5 -1 -7 6 -6 -2 -5 10 2 -10
Sample Output 3
428