No.823 Many Shifts Easy
Problem Statement
There are $N+1$ squares arranged in a row, numbered $0,1,\dots,N$ from left to right. Each of the squares numbered $1$ through $N$ has $1$ piece placed on it.
Here, for an integer sequence $A$ of length $K$ with elements between $1$ and $N$ inclusive and $\large \textbf{all elements pairwise distinct}$, define its score as the sum of the numbers of the squares that have at least $1$ piece on them after performing the following operation.
Operation: for $i=1,2,\dots,K$ in this order, move all pieces on square $A_i$ to square $A_i-1$
There are ${}_N\mathrm {P}_ K$ integer sequences of length $K$ with elements between $1$ and $N$ inclusive and $\large \textbf{all elements pairwise distinct}$.
Compute the score for every integer sequence with $\large \textbf{all elements pairwise distinct}$, and find the sum of the scores modulo $10^9+7$.
Input
$N$ $K$
$1\le K\le N\le 10^5$
Output
Output the sum of the scores over all integer sequences with $\large \textbf{all elements pairwise distinct}$, modulo $10^9+7$. Print a newline at the end.
Sample
Sample 1
Input
6 4
Output
3600
For the case $A=(2,1,5,4)$:
$i=1$: Square $2$ has $1$ piece on it, and that piece is moved to square $1$
$i=2$: Square $1$ has $2$ pieces on it, and those pieces are moved to square $0$
$i=3$: Square $5$ has $1$ piece on it, and that piece is moved to square $4$
$i=4$: Square $4$ has $2$ pieces on it, and those pieces are moved to square $3$
In the end, squares $0,3,6$ each have at least $1$ piece on them, so the score of the permutation $A=\{2,3,1,4\}$ is $0+3+6=9$
Sample 2
Input
1 1
Output
0
Sample 3
Input
1000 100
Output
45281982
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Pulmn
e869120