AtCoder Grand Contest 045
翻译中…
Problem Statement
翻译中…
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:
- Choose a lamp that is on at the moment. (The operation cannot be done if there is no such lamp.) Let Lamp
$i$be the chosen lamp. Press Button$i$, which switches the state of Lamp$p_i$. That is, Lamp$p_i$will be turned off if it is on, and vice versa.
翻译中…
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)$.
翻译中…
Constraints
翻译中…
$2 \leq N \leq 10^7$$1 \leq A \leq \min(N-1,5000)$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N A
翻译中…
Output
翻译中…
Print $w \times N!$ modulo $(10^9+7)$, where $w$ is the probability of Snuke's winning.
翻译中…
样例
Input #1
3 1
Output #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$.
Input #2
3 2
Output #2
3
Input #3
8 4
Output #3
16776
Input #4
9999999 4999
Output #4
90395416
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。