思路

//动态规划
//dp[m][n]:m个苹果放到n个盘子***有dp[m][n]中分法
//(1)如果0个苹果或者1个苹果,或者1个盘子:dp[0][n]==dp[1][n]==dp[m][1]==1;
//(2)如果有盘子为空,dp[m][n] = dp[m][n-1];
//(3)如果没有盘子为空,dp[m][n] = dp[m-n][n];

Answer

#include<stdio.h>

int main() {

    int m, n;
    int dp[11][11] = { 0 };
    while (scanf("%d%d", &m, &n) != EOF) {
        for (int i = 0; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (i == 0 || i == 1 || j == 1) {
                    dp[i][j] = 1;
                } else if (i >= j) {
                    dp[i][j] = dp[i - j][j] + dp[i][j - 1];
                } else {
                    dp[i][j] = dp[i][j - 1];
                }
            }
        }
        printf("%d\n", dp[m][n]);
    }

}