What is the number of ways to distribute $m$ indistinguishable balls to $k$ distinguishable boxes given no box can be a unique number of balls?


for example: ($m=19$ and $k=5$)
$$x\_1 + x\_2 + \dots + x\_5 = 19 $$
Some of the accepted ways are:


$2 , 2 , 5 , 5 , 5$


$3 , 3 , 3 , 5 , 5$


$8 , 1 , 1 , 1 , 8$


and some of the rejected ways are:


$6 , 6 , 1 , 1 , \mathbf{5}$


$4 , 5 , 7 , 2 , 1$


$1 , 1 , \mathbf{15} , 1 , 1$


Note that the number of zero balls in the boxes is acceptable but does not make a difference! This means that in the same case as before if we assume the number of boxes is 6, the following ways are still acceptable:


$2 , 2 , 5 , 5 , 5 , 0$


$3 , 3 , 0 , 3 , 5 , 5$


$0, 8 , 1 , 1 , 1 , 8$



Number of ways of distributing indistinguishable balls into distinguishable boxes with extra givens
Max is surely correct that there is no simple formula, though a summation or double summation is plausible. Anyway, computation via a recurrence is probably the best. Define $A(m,k)$ to the number of (ordered) compositions $a\_1+\cdots+a\_k=m$ with no unique term. Note that 0 can't be unique either in this definition.


Note that if all the zeros are removed, we can subtract 1 from each value to get another solution. That is (using $i$ for the number of 0s),
$$A(m,k) = A(m-k,k) + \sum\_{i=2}^k \binom{k}{i} A(m-k+i,k-i).$$
The boundary conditions are just the obvious, such as $A(m,1)=0$ for all $m$, $A(0,k)=1$ if $k=0$ or $k\ge 2$, etc..


To apply the special rule for 0, just include the $i=1$ term at the first step:


$$\mathrm{answer}(m,k) = \sum\_{i=0}^k \binom{k}{i} A(m-k+i,k-i).$$


