問題一覧 > 通常問題

No.1035 Color Box

レベル : / AI推定難易度 : 1150 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 251
作問者 : ningenMe / テスター : onakaT_Titai
お気に入りにしたユーザー ProblemId : 2772 / 自分の提出
問題文最終更新日: 2020-05-01 21:16:23
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 245 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。