http://ac.jobdu.com/problem.php?pid=1160
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <algorithm>
using namespace std;
#define N 1000100
/*
m个苹果放入n个盒子中:
不空的时候,将m个苹果取出n个,放入每个盒子一个,下面相当于是 m-n个苹果放入n个盒子中;
空的时候,相当于是m个苹果放入n-1个盒子中。
deal(m-n,n) + deal(m,n-1);
*/
int deal(int m,int n){
if(n==1) return 1;
else{
if(m<0) return 0;
else if(m==0) return 1;
else{
return deal(m-n,n) + deal(m,n-1);
}
}
}
int main() {
// freopen("/Users/a1/Public/20150717/20150717/in.txt","r",stdin);
int n,m;
int t;
scanf("%d",&t);
while(t--){
scanf("%d %d",&m,&n);
printf("%d\n",deal(m,n));
}
return 0;
}