#abc309g. G - Ban Permutation

G - Ban Permutation

Score : 575575 points

问题描述

求满足以下条件的从 (1,2,,N)(1,2,\dots,N) 到自身的排列 P=(P1,P2,,PN)P=(P_1,P_2,\dots,P_N) 的个数,模 998244353998244353

  • 对于所有整数 ii,满足 1iN1 \le i \le N,均有 PiiX|P_i - i| \ge X

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Find the number, modulo 998244353998244353, of permutations P=(P1,P2,,PN)P=(P_1,P_2,\dots,P_N) of (1,2,,N)(1,2,\dots,N) such that:

  • PiiX|P_i - i| \ge X for all integers ii with 1iN1 \le i \le N.

Constraints

  • 1N1001 \le N \le 100
  • 1X51 \le X \le 5
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN XX

Output

Print the answer.

Sample Input 1

3 1

Sample Output 1

2

The conforming permutations P=(P1,P2,P3)P=(P_1,P_2,P_3) are the following two, (2,3,1)(2,3,1) and (3,1,2)(3,1,2), so the answer is 22.

Sample Input 2

5 2

Sample Output 2

4

Sample Input 3

98 5

Sample Output 3

809422418

update @ 2024/3/10 08:46:58