Solution of ARC110D without formal power series
D - Binomial Coefficient is Fun
- When Bi is less than Ai, the binomial coefficient is zero
 - So there is no need to consider cases where Bi is small.
 - .
 - and the rest as [$ R:= M - S
 - .
 - It takes the form of βdistribute R (or less) balls in N frames.β
 - Consider distributing just K balls in 2 frames for simplicity
 - (0, K), (1, K-1), β¦ , (K, 0), there is a way to distribute
 - The solution X2 we want is
 - There is a way to implement this naively and obtain it for some values and predict the answer formula from them (I did so), but in this page, I will do it by transforming the formula.
 - From the symmetry of the binomial coefficients
 - 
- nested combination : number of ways to select k out of n, allowing for duplication
 
 - Write in the form of duplicate combinations:.
 - Duplicate combinations of A1+1 to i and A2+1 to K-i contents of sigma to choose from
 - Adding up for all possible iβs results in K duplicate combinations to choose from A1+A2+2.
 - Return to binomial coefficient form
 - So far, the answer for distributing exactly K with N=2 can be expressed in terms of a single binomial coefficient
 - Next, consider N over 3.
- Rename variable K to i
 - At this point, X at N=3 becomes
 - This is just A1 becoming A1+A2+1, so the argument above can be used as is.
 
 - Rename variable K to i
 - At general N:.
- This was just the solution when they were handing out K pieces.
 - The answer X that the problem is asking for is the sum of everything below R
 - Field hockey stick identity :
 
 - Field hockey stick identity to find the sum
 - From the symmetry of the binomial coefficients
 - , so
 - Now the values to be sought are combined into a single binomial coefficient.
 - N+M will be about 10^9, but S+N will not be 10^7, so if properly implemented, it will be in time. - Binomial coefficient for huge n
 
This page is auto-translated from [/nishio/ARC110D nonFPS](https://scrapbox.io/nishio/ARC110D nonFPS) using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. Iβm very happy to spread my thought to non-Japanese readers.