Score : 1200 points
We have N lamps numbered 1 to N, and N buttons numbered 1 to N. Initially, Lamp 1, 2, \cdots, A are on, and the other lamps are off.
Snuke and Ringo will play the following game.
First, Ringo generates a permutation (p_1,p_2,\cdots,p_N) of (1,2,\cdots,N). The permutation is chosen from all N! possible permutations with equal probability, without being informed to Snuke.
Then, Snuke does the following operation any number of times he likes:
At every moment, Snuke knows which lamps are on. Snuke wins if all the lamps are on, and he will surrender when it turns out that he cannot win. What is the probability of winning when Snuke plays optimally?
Let w be the probability of winning. Then, w \times N! will be an integer. Compute w \times N! modulo (10^9+7).
Input is given from Standard Input in the following format:
N A
Print w \times N! modulo (10^9+7), where w is the probability of Snuke's winning.
3 1
2
First, Snuke will press Button 1. If Lamp 1 turns off, he loses. Otherwise, he will press the button that he can now press. If the remaining lamp turns on, he wins; if Lamp 1 turns off, he loses. The probability of winning in this game is 1/3, so we should print (1/3)\times 3!=2.
3 2
3
8 4
16776
9999999 4999
90395416