How to count all restricted partitions of the number $155$ into a sum of $10$ natural numbers between $[0,30]$? How to count all restricted partitions of the number $155$ into a sum of $10$ natural numbers between $[0,30]$?
I really have no clue what to do with this one. Thanks for any help!
 A: We can find the number of restricted partitions of $n$ into $k$ elements in $\{0,1,\dots, m\}$ in time $nkm$ using a $2$-d knapsack.
To do this let $A[i][j]$ be the number of resitricted partitions of $i$ into $j$ summands and actualize $A$ to incorporate each of the $m+1$ numbers one by one.
Some code:
#include <bits/stdc++.h>
using namespace std;

const int MAX=200;
int A[MAX][MAX]; // the array

int main(){
    int N=155,K=10,M=30;
    for(int i=0;i<=K;i++){ // set it up so that the number 0 can be formed in 1 way for any number of summands
        A[0][i]=1;
    }
    for(int i=1;i<=M;i++){ // incorporate the number i as a possible summand
        for(int j=i;j<=N;j++){ // actualize the number of ways to form the number j starting from j=i
            for(int l=1;l<=K;l++){ 
                A[j][l]+=A[j-i][l-1]; // the number of ways to make j with l summands increases by A[j-i][l-1]
            }
        }
    }
    printf("%d\n",A[N][K]);
}

output is $10270579$
A: So, formalised problem is
$$\sum\limits_{k=1}^{10} x_k=155$$
$$0\leq x_k\leq 30, \forall k=1..30$$
Using the following generating function (here is an example also pointing to other examples and a book)
$$(1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+\\x^{10}+x^{11}+x^{12}+x^{13}+x^{14}+x^{15}+x^{16}+x^{17}+x^{18}+x^{19}+\\x^{20}+x^{21}+x^{22}+x^{23}+x^{24}+x^{25}+x^{26}+x^{27}+x^{28}+x^{29}+x^{30})^{10}$$
and a computer (to avoid tedious calculations) to find the coefficient of the $x^{155}$ term, the answer is $11219423909980$. 
But this question isn't totally clear, as per the question Rob raised in the comments and 2 closing votes. It turns out, there is a definition of  restricted partitions as defined here. That link also states the generating function as Theorem 3.1 (same result here, as $(3.9)$).
A: So you are looking for 
$$
N_p (s,r,m) = {\rm No}{\rm .}\,{\rm of}\,{\rm integer}\;{\rm solutions}\;{\rm of}\left\{ \matrix{
  0 \le x_{\,j}  \le r \hfill \cr 
  x_{\,j}  \le x_{\,j + 1}  \hfill \cr 
  \sum\limits_{1\, \le \,j\, \le \,m} {x_{\,j} }  = s \hfill \cr}  \right.
$$
Now, while the number of restricted Compositions
$$N_{\,b} (s,r,m) = \text{No}\text{. of solutions to}\;\left\{ \begin{gathered}
  0 \leqslant \text{integer  }x_{\,j}  \leqslant r \hfill \\
  x_{\,1}  + x_{\,2}  +  \cdots  + x_{\,m}  = s \hfill \\ 
\end{gathered}  \right.$$
can be expressed by
$$
N_b (s,r,m)\quad \left| {\;0 \leqslant \text{integers  }s,m,r} \right.\quad  = \sum\limits_{\left( {0\, \leqslant } \right)\,\,k\,\,\left( { \leqslant \,\frac{s}
{r}\, \leqslant \,m} \right)} {\left( { - 1} \right)^k \left( \begin{gathered}
  m \hfill \\
  k \hfill \\ 
\end{gathered}  \right)\left( \begin{gathered}
  s + m - 1 - k\left( {r + 1} \right) \\ 
  s - k\left( {r + 1} \right) \\ 
\end{gathered}  \right)} 
$$
as explained in this other post, and $Nb(155,30,10)$ gives the value provided by rtybase.
I also have been looking for an expression for the Partitions, but did not succeed in that.
