A really nice problem occured in ABC 471, if I was smarter I would’ve been able to solve it faster but I did get to a solution and was satisfied with just that too; but to get better must distill it.
Problem
There are balls numbered to . Ball has an integer written on it.
For a way of choosing some balls from the balls, define the score of that choice as
Try to solve this problem for different .
I am familiar with the idea of counting contributions and this is just a simplified application of it.
For each you can ask, how many choice sets will this be part of? Since one is fixed, you can just choose from the remaining , so contribution for “this” is , sum it over and you have your solution
$$\sum_i \binom{n-1}{k-1} A_i$$$
This was the original problem from the contest. The solution that I arrived at followed a recursive logic and I wouldn’t call it as clean as the intended solution which leans closes to the general solution to the problem as well.
Solution 1 : decompose to terms and count contribution individually
Same as the case for contribution counting but we’re applying it here.
In the expansion of the square, you would have terms as well as terms. It’s important to be precise here otherwise we run the risk of over/under counting based on arrangements.
In the expansion of , coefficients of would be , so it’s contribution would be “how many choices will this be included in, and from each we’ll have one term. This gets you to
$$\sum_i \binom{n-1}{k-1} A_i^2$$$
via a similar argument as .
Now about the case, well, what is it’s coefficient in the expansion above? it’ll be . This is simply because I get one of and one of , so depending on how I count; using or , you get get a different contribution count and it’s essential to not mix it up.
For a “set” as , how many times will this be in the choices? Well, you fix two and pick the rest in ways, note that since what I fixed was “set” I am working on the case. Put simply, if you ask is this to be counted separately for or and you would know it. I cannot write it better and those are the limits of my own writing. I think I understand it but this inability perhaps hints as something still left to be desired.
The contribution then is or
Both are obviously identical of course.
Focus on computing the pair product now. For this case, it’ll simply be
I deliberaly did not write the RHS rigorously since this was the source of my error, which one of the above do I choose? Depening on what I choose, I may or may not get a factor of two.
Given that I’ve done the groundwork of highlight a possble gap, it’s obvious we choose the first one, since this is what you get as the pair product naturally.
Thus the whole solution, written in a way that’s computationally obvious to be is
Solution 2 : choose one and recurse into
This is what I did, somewhat incorrectly too, but also leads to the same solution.
Difference only lies in the pair product contribution argument.
Say you choose an and fix it, then you can decompose as
how many times would a certain occur in the inner sum? That’s . Where I made a mistake was also counting , missing the obvious sanity check that perhaps the terms are exploding too much with the double binomial product. When I write it this way, it’s clear that for each , I’ve applied the contribution handling inside od the summation.
Define
then contribution of product terms for a give is . No need of additioanl coefficients as the s are all , for every , every product is handled too. The solution then is
this cleverly skips the pair product but the first one is more straighforward to reach to.
This is where I realise that what we’re working with are “partitions”. I’ll try not to repeat myself, just the new stuff.
Contribution of term is .
Contribution of term is Note that here is , as by choosing we do not arrange, but the product will have that term repeated — see the parallels to multinomial.
is where it starts to get tricky. Do we need a ? No, if you are under .
Notice that here the terms for , the equation is not symmetric. It’s easier to work with an example.
it’s simply that we are doing it differently for THIS case by working under a regime for the second term.
For calulating those products now, define
Now if you go via a similar way as I did in my solution , for case .
these above are also known as Newton’s identities as well where he tried to relate power sums to such
Combining it all, you get to.
There is a pattern here, and it’s possble to generalise.
Multinomial theorem for gives you this for a single monomial.
Note that even though the maths works out for the monomial above, to find out how many of such terms exist we contrain to and work out solutions of .
First the binomial coefficient, for an to be chosen it means it’s multiplicitiy is i.e. For a term where some set of balls are already chosen, and we wish to find how many times this set will occur, exclude ( reusng r here ) and get to
Arranging them for the number of times that product occurs ( it’s coeffiecient in the multinomial ) gives you
One such term would be adding this to the score
And we want all such terms where
Combining all this gets you to
where
Appendix: relation to Sterling numbers
P distinct balls into r identical boxes, with no box empty is .
In my case, the boxes are not identical so need to arrange by , both these are same
Well, I mean this relation and it’s mention here does not bring much to the table here.