#abc309g. G - Ban Permutation
G - Ban Permutation
Score : points
问题描述
求满足以下条件的从 到自身的排列 的个数,模 :
- 对于所有整数 ,满足 ,均有 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Find the number, modulo , of permutations of such that:
- for all integers with .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 1
Sample Output 1
2
The conforming permutations are the following two, and , so the answer is .
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