Public Judge

pjudge

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100
الإحصائيات

给定一个正整数序列 $a_1,a_2,...,a_n(a_1 < a_2 < ... < a_n)$,序列中没有相同的元素。

求有多少个 $1\sim n$ 的排列 $p_1,\dots,p_n$,满足对所有 $1≤i≤n−1$,有 $|a_{p_i} - a_{p_{i+1}}| \ne k$,答案在模 $998244353$ 意义下输出。

输入格式

第一行两个整数 $n,k$。

第二行 $n$ 个整数 $a_1,a_2,\cdots,a_n$。

输出格式

输出一行一个整数表示答案。

输入输出样例

样例输入 1

4 1
1 2 3 4

样例输出 1

2

样例解释 1

$3,1,4,2$ 和 $2,4,1,3$ 满足条件。

样例输入输出 2,3

见下发文件。

数据范围

对于所有数据,有:

  • $1 \le n \le 5 \times 10^3$
  • $1 \le k \le 10^6$
  • $1 \le a_i \le 10^9$
子任务编号 特殊性质 分值
$1$ $n \le 10$ $20$
$2$ $n \le 400$ $30$
$3$ $n \le 1000$ $20$
$4$ 无特殊性质 $30$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.