Comments

Let's write

$$$\displaystyle f(x) = \frac{(A + B + C - 2x)!}{(A - x)!(B - x)!(C - x)!x!}$$$

a function which counts the number of strings with $$$A - x$$$ a's, $$$B - x$$$ b's, $$$C - x$$$ c's and $$$x$$$ special characters "?".

Now, if we replace each apparition of "?" with "abc", this counts the strings with at least $$$x$$$ substrings equal to "abc", with one caveat: it counts strings with $$$y \geq x$$$ multiple times. How many times? Well, if a string has $$$y$$$ "abc"s and we choose to replace $$$x$$$ of them with "?", then it counts that string $$$y \choose x$$$ times.

Thus, if the actual count of strings with exactly $$$x$$$ substrings equal to "abc" is $$$s(x)$$$, and for any $$$x \gt min(A,B,C)$$$ by definition $$$s(x) = 0$$$, we have

$$$\displaystyle f(x) = \sum_{y=x}^{\infty} {y \choose x} * s(x)$$$

Now, the answer is

$$$\displaystyle S = \sum_{i = 0}^{min(A, B, C)} (-1)^i f(i)$$$

The factor for $$$s(x)$$$ in $$$S$$$, $$$0 \leq x \leq min(A,B,C)$$$ is

$$$\displaystyle C_x = \sum_{y=0}^{x} (-1)^y {x \choose y}$$$

For any $$$x \geq 1$$$, it is known that $$$C_x = 0$$$. Finally,

$$$S = s(0) + \sum_{x=1}^{min(A,B,C)} C_x * s(x) = s(0)$$$
+26

As a tester, I am happy to represent my fellow newbies. The round has good and enjoyable problems. Good luck!

When are we getting the more general tutorial for how Everything Flows?

+18

I've been enjoying your blogs comments recently but I've noticed a significant lack of anime references in them. Needless to say I am dissapointed.

On AlexLuchianovHow NOT to use macros, 4 years ago
+26

Khajiit has macros if you have coin.

+85