luogu#P3904. 三只小猪

    ID: 2858 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>高精度递推组合数学排列组合线性递推

三只小猪

Background

Have you heard the story of the Three Little Pigs? It is a classic tale. Long, long ago, there were three little pigs. The first little pig built a house of straw, the second little pig built a house of sticks, and the third little pig used bricks as the material. A big bad wolf wanted to eat them and blew down the straw house and the stick house. But the brick house was very sturdy, and the wolf failed to destroy it. In the end, the little pigs defeated the wolf and burned its tail.

Problem Description

For their safety, the little pigs built another new brick house. But now a problem arises: how should the three little pigs be assigned to the two houses? The third little pig is the smartest of the three. To avoid wasting any house, it considered a total of three plans, as shown below.

"But what about the future?" The third little pig knows that as their group grows, they will build more houses. It wants to know, given the numbers of houses and pigs, how many allocation plans there are. However, this problem is clearly a bit hard for it. Can you help the little pig solve it?

Input Format

The input contains a single line with two integers nn and mm, denoting the number of pigs and the number of houses (1n,m501 \leq n, m \leq 50).

Output Format

Output a single integer: the number of ways to place nn pigs into mm houses such that no house is left empty.

4 2
7
6 7
0

Hint

Translated by ChatGPT 5