#P1287. 盒子与球

盒子与球

Description

There are rr distinct boxes and nn distinct balls. Put these nn balls into the rr boxes, with no box left empty. Find how many different placements there are.

Two placements are different if and only if there exists a ball that is placed into different boxes in the two placements.

Input Format

The input contains one line with two integers, representing nn and rr.

Output Format

Output one line with a single integer representing the answer.

3 2

6

Hint

Sample Explanation 1

There are two boxes (IDs 1,21, 2) and three balls (IDs 1,2,31, 2, 3), for a total of six arrangements, as follows:

Box ID Arrangement 1 Arrangement 2 Arrangement 3 Arrangement 4 Arrangement 5 Arrangement 6
Box 11 Ball 11 Ball 22 Ball 33 Balls 2,32, 3 Balls 1,31, 3 Balls 1,21, 2
Box 22 Balls 2,32, 3 Balls 1,31, 3 Balls 1,21, 2 Ball 11 Ball 22 Ball 33

Constraints

For 100%100\% of the testdata, it is guaranteed that 0rn100 \leq r \leq n \leq 10, and the answer is less than 2312^{31}.

Translated by ChatGPT 5