Codeforces Round 177 (Div. 1)
B
Polo the Penguin and Houses
Codeforces
1500
原题
← AC →
翻译中…

Little penguin Polo loves his home village. The village has $*n*$ houses, indexed by integers from 1 to $*n*$. Each house has a plaque containing an integer, the $*i*$-th house has a plaque containing integer $*p*_{*i*}$ ($1 ≤ *p*_{*i*} ≤ *n*$).

翻译中…

Little penguin Polo loves walking around this village. The walk looks like that. First he stands by a house number $*x*$. Then he goes to the house whose number is written on the plaque of house $*x*$ (that is, to house $*p*_{*x*}$), then he goes to the house whose number is written on the plaque of house $*p*_{*x*}$ (that is, to house $*p*_{*p*_{*x*}}$), and so on.

翻译中…

We know that:

翻译中…
  1. When the penguin starts walking from any house indexed from 1 to $*k*$, inclusive, he can walk to house number 1.
  2. When the penguin starts walking from any house indexed from $*k* + 1$ to $*n*$, inclusive, he definitely cannot walk to house number 1.
  3. When the penguin starts walking from house number 1, he can get back to house number 1 after some non-zero number of walks from a house to a house.
翻译中…

You need to find the number of ways you may write the numbers on the houses' plaques so as to fulfill the three above described conditions. Print the remainder after dividing this number by $1000000007$ $(10^{9} + 7)$.

翻译中…

Input

翻译中…

The single line contains two space-separated integers $*n*$ and $*k*$ ($1 ≤ *n* ≤ 1000, 1 ≤ *k* ≤ *min*(8, *n*)$) — the number of the houses and the number $*k*$ from the statement.

翻译中…

Output

翻译中…

In a single line print a single integer — the answer to the problem modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

样例

Input #1
5 2
Output #1
54
InputCopy OutputCopy
Input #2
7 4
Output #2
1728
InputCopy OutputCopy
题目信息
题号
288B
时间限制
2 s
内存限制
256 MB
标签
组合数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。