G - Ban Permutation
解説
/
実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 575 点
問題文
(1,2,\dots,N) の順列 P=(P_1,P_2,\dots,P_N) のうち、以下の条件を満たすものの個数を 998244353 で割ったあまりを求めてください。
- 1 \le i \le N を満たす全ての整数 i に対して、|P_i - i| \ge X である。
制約
- 1 \le N \le 100
- 1 \le X \le 5
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N X
出力
答えを出力せよ。
入力例 1
3 1
出力例 1
2
条件を満たす順列 P=(P_1,P_2,P_3) は、(2,3,1),(3,1,2) の 2 個です。よって答えは 2 です。
入力例 2
5 2
出力例 2
4
入力例 3
98 5
出力例 3
809422418
Score : 575 points
Problem Statement
Find the number, modulo 998244353, of permutations P=(P_1,P_2,\dots,P_N) of (1,2,\dots,N) such that:
- |P_i - i| \ge X for all integers i with 1 \le i \le N.
Constraints
- 1 \le N \le 100
- 1 \le X \le 5
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N X
Output
Print the answer.
Sample Input 1
3 1
Sample Output 1
2
The conforming permutations P=(P_1,P_2,P_3) are the following two, (2,3,1) and (3,1,2), so the answer is 2.
Sample Input 2
5 2
Sample Output 2
4
Sample Input 3
98 5
Sample Output 3
809422418