【题解】1st ucup Stage 20: India G - Perfect Strings
考虑卡特兰数 \(C_n = \sum_{i=0}^{n-1}C_iC_{n-1-i}\),故有递推式
\[C = xC^2 +1
\]
解出卡特兰数递推式:
\[C = \frac{1 - \sqrt{1 - 4x}}{2x}
\]
考虑本题的递推式:
\[F_n = \sum_{i=0}^{n-1}\frac{c}{c-1}C_iF_{n-1-i}
\]
令 \(B = c /(c - 1)\)故有
\[F = xBCF + 1 \\
F = \frac{1}{1-xBC}\\
F = \frac{1-\frac{B}{2}-\frac{B}{2}\sqrt{1-4x}}{(-B+1)+B^2x}
\]
\(\sqrt{1-4x} = 1-2xC\) 令
\[F = \frac{1}{1-B} \cdot \frac{1 - B + xBC}{1-\frac{B^2}{B-1}x}
\]