题目描述
Problem Description
There are $ N $ people, each pointing at one other person (other than themselves). No one is left unpointed.
When each person reports after how many steps they return to themselves, the maximum value is $ K $ steps.
Let's count how many such pointing arrangements exist. When counting the pointing arrangements, people are distinguished from each other.
The number of pointing arrangements can be very large, so find the remainder when divided by $ 1,000,000,007(=10^{9}+7) $.
Input Format
The input is given from the standard input in the following format:
$ N $ $ K $
- The first line contains two integers $N(2\ \leq\ N\ \leq\ 1000)$ and $K(1\ \leq\ K\ \leq\ N)$ separated by a space.
Output Format
Output the number of pointing arrangements modulo $ 1,000,000,007 $ in one line. Ensure a newline at the end of the output.
Sample Input and Output
Sample Input #1
3 3
Sample Output #1
2
Sample Input #2
4 2
Sample Output #2
3
Sample Input #3
3 2
Sample Output #3
0
Sample Input #4
1000 1000
Sample Output #4
756641425
Notes/Hints
Partial Points
This problem has partial points.
- If you solve the dataset where $2\ \leq\ N\ \leq\ 8$, you get $ 10 $ points.
- If you solve all datasets, you get an additional $ 140 $ points. The total is $ 150 $ points.
Sample Explanation 1
When each person is numbered $ 1 $, $ 2 $, $ 3 $, there are two pointing arrangements: $ 1 $→$ 2 $→$ 3 $→$ 1 $ and $ 1 $→$ 3 $→$ 2 $→$ 1 $.
Sample Explanation 2
When each person is numbered $ 1 $, $ 2 $, $ 3 $, $ 4 $, there are three pointing arrangements: $ 1 $→$ 2 $→$ 1 $, $ 3 $→$ 4 $→$ 3 $; $ 1 $→$ 3 $→$ 1 $, $ 2 $→$ 4 $→$ 2 $; and $ 1 $→$ 4 $→$ 1 $, $ 2 $→$ 3 $→$ 2 $.
Sample Explanation 3
There may be no pointing arrangement that satisfies the conditions.
Sample Explanation 4
The answer can be very large, so output the remainder when divided by $ 1,000,000,007 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分