QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 256 MB Points totaux : 100

#22351. 混乱的牛

Statistiques

Farmer John 的 $N$ 头牛($(4 \le N \le 16)$)各有唯一编号 $S_{i}$($(1 \le S_{i} \le 25,000)$)。它们十分自豪,每头都像帮派成员一样,把大字刻着编号的金牌挂在粗壮的脖子上。

叛逆的牛以称为“混乱”的顺序排队挤奶。如果队列中每对相邻牛的编号差都严格大于 $K$($(1 \le K \le 3400)$),此顺序就是“混乱”的。例如 $N = 6$、$K = 1$ 时,1, 3, 5, 2, 6, 4 合格,1, 3, 6, 5, 2, 4 不合格,因为相邻5和6只差1。

$N$ 头牛有多少种不同的混乱排列?

前10次提交会提供程序在部分实际测试数据上的运行结果。

输入格式

  • 第1行:两个空格分隔整数 $N$ 和 $K$。
  • 第 $2,\ldots,N+1$ 行:第 $i+1$ 行含一个整数,即第 $i$ 头牛编号 $S_{i}$。

输出格式

  • 第1行:一个整数,$N$ 头牛的混乱排列数。保证答案能用64位整数表示。

样例

输入格式 1

4 1
3
4
2
1

输出格式 1

2

说明

两种混乱排列如下:3 1 4 2 2 4 1 3。

子任务

分数:200

题目作者:Don Piele, 2007

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.