QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 256 MB Puntuación total: 100

#1284. 划分数

Estadísticas

给定一个整数集合 $A = \{a_1, a_2, \dots, a_n\}$。请计算方程 $x_1 + x_2 + \dots + x_k = m$ 的解的个数,其中 $x_i$ 为正整数,$x_1 \le x_2 \le \dots \le x_k$ 且 $x_i \notin A$。

由于答案可能非常大,你只需要计算其对 $(10^9 + 7)$ 取模的结果。

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$,表示测试数据的组数。对于每组测试数据:

第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 500, n \le m \le 3 \cdot 10^5$)。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le m, a_i \neq a_j$ 对于所有 $i \neq j$)。

保证所有测试数据的 $n$ 之和不超过 $500$。

输出格式

对于每组测试数据,输出一个整数表示答案。

样例

样例输入 1

5
1 4
1
1 4
2
1 4
3
3 4
1 2 3
4 4
1 2 3 4

样例输出 1

2
3
4
1
0

说明

当 $m = 4$ 且约束集合 $A$ 为空时,共有 $5$ 种解。它们分别是:

$4 = 1 + 1 + 1 + 1$ $= 1 + 1 + 2$ $= 1 + 3$ $= 2 + 2$ $= 4$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.