题解 | #放苹果#
放苹果
http://www.nowcoder.com/practice/bfd8234bb5e84be0b493656e390bdebf
#include<stdio.h>
int size;
void dfs(int max, int m, int n) {
if (m==0||n==0){
size+=m==0;
return;
}
for (int i = m>max?m-max:0;i< m; i++)
dfs(m-i, i, n - 1);
}
int main() {
int m, n;
while (~scanf("%d%d", &m, &n)) {
size = 0;
dfs(m, m, n);
printf("%d\n", size);
}
}