QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 512 MB Points totaux : 70

#15386. 节日

Statistiques

在今年的巧克力节上,Ivan 正在工作。他的老板给了他 $n$ 颗不同的巧克力糖,并要求他用这些糖果准备 $k$ 个巧克力盒子。在开始整理盒子之前,Ivan 想知道他有多少种不同的整理方式,然后在考虑所有可能性后,他将选择最好的整理方案。

巧克力节是一项非常重要且严肃的活动,因此糖果必须完美地整理。为了实现这一目标,Ivan 知道他必须遵守以下规则:

  • 每个盒子必须包含至少一颗糖果。
  • 每颗糖果必须恰好放入一个盒子中。
  • 他使用的盒子是完全相同的,因此交换两个盒子的内容物不会产生新的整理方案。唯一重要的是哪些糖果在哪个盒子中,以及它们在盒子里的排列顺序。
  • 最大的糖果总是排在盒子的第一位。我们可以假设在任何一组糖果中,最大的糖果总是可以被唯一确定。

Ivan 有多少种不同的方式来整理这些盒子?由于方案数可能非常大,请将其对 $10^9 + 7$ 取模后输出。

输入格式

第一行也是唯一的一行包含自然数 $n$ 和 $k$($1 \le n \le 5000$,$1 \le k \le n$),分别表示糖果的数量和盒子的数量。

输出格式

在第一行也是唯一的一行中,输出一个整数——Ivan 整理盒子的方案数模 $10^9 + 7$ 的结果。

子任务

子任务 分值 附加限制
1 8 $k = 1$
2 19 $k = 2$
3 14 $n \le 10$
4 29 无附加限制。

样例

输入样例 1

3 1

输出样例 1

2

输入样例 2

3 2

输出样例 2

3

输入样例 3

4 2

输出样例 3

11

说明

样例 1 解释:

我们将糖果从小到大标记为 $1$、$2$ 和 $3$。我们需要将它们整理在一个盒子中,因此所有三颗糖果必须在同一个盒子中。糖果 $3$ 必须排在第一位,因为它是最大的。我们可以用两种方式排列其余两颗糖果,因此 [3, 1, 2][3, 2, 1] 是仅有的两种有效整理方案。

样例 2 解释:

我们将糖果从小到大标记为 $1$、$2$ 和 $3$。我们可以用三种方式整理这些糖果:{[1], [3, 2]}{[2], [3, 1]}{[3], [2, 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.