No.1035 Color Box
タグ : / 解いたユーザー数 251
作問者 :
onakaT_Titai
Problem Statement
There are $N$ boxes, each labeled with a distinct number from $1$ to $N$, and you paint them using $M$ kinds of paint.
All $M$ colors must be used, and every box must be painted with some color.
How many ways are there to paint the boxes? Since the answer can be very large, output it modulo $10^9+7$.
Input
$N\ M$
$1 \le M\le N \le 10^5$
All inputs are integers.
Output
Output the answer on a single line, followed by a newline.
Sample
Sample 1
Input
3 2
Output
6
Let the paint colors be $1$,$2$ and let ($a$,$b$,$c$) denote the colors of the 3 boxes. Then there are 6 ways to paint them: ($a$,$b$,$c$)=($1$,$1$,$2$),($1$,$2$,$1$),($2$,$1$,$1$),($2$,$2$,$1$),($2$,$1$,$2$),($1$,$2$,$2$).
Sample 2
Input
4 4
Output
24
Sample 3
Input
100000 100000
Output
457992974
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。