http://ac.jobdu.com/problem.php?pid=1160
参考了
1.http://blog.csdn.net/qq276592716/article/details/6851673
#include <stdio.h>
#include <cstring>
int func(int m,int n){
if(m < 0) return 0;
//There is no apple or only one plates
if(m==0|| n==1) return 1;
/*Put apples from 1 to n: `1` with least apples, `n` with most apples on quality
*when none apple was put on first plate, there would be f(m,n-1) possiblities;
*when some apples were put on the first plate, f(m-n,n) possibilities,
*since we put one apple on each plates would be the same possiblities as f(m,n)
**/
//first plate put none + first plate put some apples
return func(m,n-1) + func(m-n,n);
}
int main(){
int m,n,t;
scanf("%d",&t);
while(t--){
scanf("%d%d",&m,&n);
printf("%d\n",func(m,n) );
}
}