fork download
  1. int recurse(int N,int K)
  2. {
  3. if(N==0)return K==0;
  4. if(K<0 ||N <0 )return 0;
  5. return recurse(N,K-N)+recurse(N-1,K);
  6. }
  7. int main()
  8. {
  9. printf("%d\n",recurse(3,4));//Balls=1 and boxes = 1
  10. return 0;
  11. }
  12.  
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
4