QOJ.ac

QOJ

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

#5316. Xavier 正在学习计数

Estadísticas

Xavier 是一名 9 岁的小学生,他非常喜欢玩各种各样的益智游戏。他最喜欢的游戏之一如下:

他的同学 Xerier 制作了许多卡片,并在每张卡片上写下了一个正整数。不同卡片上的数字各不相同。之后,Xerier 写下一个等式,等式的右边是她选择的一个正整数,左边是 $p$ 个整数的和: $$X_1 + X_2 + \dots + X_p = n$$

然后,她要求 Xavier 将 $p$ 张卡片放在对应的 $X_i$ 位置上,使得等式成立,并附加一个条件:$X_i$ 必须按从小到大的顺序排列,即: $$X_i < X_{i+1}, \forall 1 \le i < p$$

每次 Xavier 都能很快想出许多种解法。现在,他想知道对于 Xerier 给出的任意 $n$,总共有多少种解法。

输入格式

输入包含多组测试数据。输入的第一行给出了测试数据的组数。接下来依次是各组测试数据。

对于每组测试数据: 第一行包含两个空格分隔的整数 $m$ 和 $p$ ($1 \le p \le 5$)。 第二行包含 $m$ 个不同的正整数,即写在每张卡片上的数字。这些整数均不超过 $13000$。

总共有约 120 组测试数据,其中 90% 的数据规模较小。更具体地说,在 90% 的测试数据中,所有数字都小于或等于 100。

输出格式

对于每组测试数据: 对于每个正整数 $n$,输出其解的个数,每行一个。为了使输出有限,仅输出解的个数大于 0 的 $n$。

每组测试数据后输出一个空行。详细格式请参考样例。

样例

输入 1

3
3 3
1 2 3
5 4
1 3 5 6 7
10 3
1 2 3 4 5 6 7 8 9 10

输出 1

Case #1:
6: 1

Case #2:
15: 1
16: 1
17: 1
19: 1
21: 1

Case #3:
6: 1
7: 1
8: 2
9: 3
10: 4
11: 5
12: 7
13: 8
14: 9
15: 10
16: 10
17: 10
18: 10
19: 9
20: 8
21: 7
22: 5
23: 4
24: 3
25: 2
26: 1
27: 1

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.