Assume that we have B balls (all the same) and C numbered containers (distinguishable). We want to calculate how many of the total combinations contain exactly 1 container with 2 balls, exactly 2 containers with 2 balls, etc.
The way I see it, first step is to calculate the different ways that we can distribute the B balls in C containers, assuming that each container can have any number of balls, including zero. According to the Stars and bars paradigm, assuming that I am not making a mistake, this should be: $\dbinom{B+C-1}{C-1}$
Second step is to calculate how many of those combinations have:
- exactly 1 container with 2 balls
- exactly 2 containers with 2 balls
- exactly 3 containers with 2 balls
- etc
which I have no idea how to do and any leads or suggestions are greatly appreciated!
Hint: Try to use the generalized inclusion exclusion principle. http://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle#A_generalization