How many ways are there to get the number with the sum of $n$ nonnegative integers with constraints?

33 Views Asked by At

Imagine I have $n$ nonnegative integers $a_1$, $a_2$, $a_3$, $\dots$, $a_n$. I also have two constants $M$ and $B$. How many sets of nonnegative $(v_1, v_2, v_3 ,\dots, v_n)$ are there so that they satisfy: $$a_1v_1 + a_2v_2 + \cdots + a_nv_n \le B,$$ and $$v_1+v_2+v_3 + \cdots +v_n = M.$$