title: Number of ways to divide n objects in k groups, such that no group will have fewer objects than previously formed groups?
body: <p>Example:
  n=8, k=4
  Answer: 5</p>
  
  <p>[1,1,1,5], [1,1,2,4], [1,1,3,3], [1,2,2,3], [2,2,2,2]</p>
  
  <p>I thought of applying dynamic programming to count the number of ways 8 objects can be divided into 4 groups, but can't understand how to keep track of the number of objects in the previous group.</p>
  
  <p>DP approach:</p>
  
  <pre><code>for(int j=0;j&lt;=n;j++)
  {
      for(int i=1;i&lt;=k;i++)
      {
          if(j&lt;i)
              continue;
          if(j==i)
              dp[j]=1;
          for(int k=1;k&lt;i;k++)
          {
              dp[j]+=dp[k]*dp[j-k];
          }
      }
  }
  </code></pre>
  
  <p>Please help with the approach. I'm relatively new to DP.</p>