luogu#P1655. 小朋友的球

    ID: 645 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划 DP高精度洛谷原创组合数学Stirling 数洛谷月赛

小朋友的球

Problem Description

A kid recently became very fond of balls. One day, he took NN distinct balls out of his pocket and wants to put them into MM identical boxes, with at least one ball in each box. He wonders how many ways there are. He tried to write a program, but since he slacks off and only watches swimming coaches on Bilibili, he asks you for help.

Input Format

Multiple test cases. Each line contains two integers N,MN, M.

Output Format

For each test case, output a single line with the number of ways.

4 2
1 1
7
1

Hint

  • For 20%20\% of the testdata, N,M10N, M \leq 10.
  • For 100%100\% of the testdata, 1N,M1001 \leq N, M \leq 100, and there are at most 1010 test cases per test file.

Translated by ChatGPT 5