Luo Valley P5564: [Celeste-B] Say Goodbye

Topic Portal: Luo Gu P5564 .

Description meaning of the questions:

There \ (n-\) points, stained \ (m \) colors, the \ (I \) color stained exactly \ (cnt_i \) nodes satisfy \ (cnt_1 + cnt_2 + \ cdots + cnt_m = n \) .

This demand \ (n-\) points consisting essentially different from the unlabeled + ordered (ordered subtree) cycloalkyl group (the loop length is at least \ () 2 \ ) the number of tree.

Essentially the same two ring if and only if the tree by rotation (not inverted) such that they can be exactly the same ring.

answer:

First consider only one color dyed \ (n-\) points ( \ (n-\ GE1 \) ) is the number of unlabeled ordered rooted tree count.
Consider the tree sequence parentheses, brackets found order of length \ (n-\) legitimate bracket string, but must satisfy the outermost brackets (root node) only one pair.
That \ (n-\) has a number of points ordered tree roots \ (n-1 \) of parentheses legitimate bracket string, ie \ (n-1 \) a number Cattleya.
Order \ (n-\) points with a number of ordered tree roots \ (T_n \) , was allowed to OGF \ (\ displaystyle T = \ sum_ {i = 1} ^ {+ \ infty} t_ix ^ i \ ) , i.e. \ (T = xC \) , where \ (C \) is the number of OGF Cattleya.

Then consider dyeing, as long as the order is not difficult to find, the dyeing and tree forms are independent of each other.
I.e., as long as the number of combinations multiplied by a multiple \ (\ displaystyle \ binom {n } {cnt_1, cnt_2, \ ldots, cnt_m} \) can.


Back to the original question, the enumeration loop length \ (k \) , using a number of statistical equivalence classes of Burnside. Statistical Methods rotating ring is replaced with a common, i.e. enumerated factor \ (D \) , equivalent to the cycle \ (D \) cell number is replaced with \ (\ varphi \! \ Left (\ dfrac {k} D} {\ right) \) . There are:

\[\begin{aligned}\mathbf{Ans}&=\sum_{k=2}^{n}\dfrac{1}{k}\sum_{d|k}\varphi\!\left(\dfrac{k}{d}\right)\!\cdot f(d)\end{aligned}\]

Wherein \ (f (d) \) represents the cyclic \ (D \) the number of cells at the fixed point.

Cycle \ (D \) grid, there is \ (D \) length of \ (\ dfrac {k} { d} \) cycle, each element within the loop represents a tree outward. In order to facilitate further expand exchange \ (D \) and \ (\ dfrac {k} { d} \) meaning enumeration \ (D \) is the cycle length, while \ (\ dfrac {k} { d} \) is the number of cycles. At this time, in each cycle tree form independently of one another, and each independently staining and tree form, but the form of the tree must be the same for each cycle, and stained must be identical, i.e. have \ (\ dfrac {k} { d} \) tree, and the total number of points is \ (\ {n-dfrac} {D} \) , and the number of each color required to meet the \ (D \) multiple, i.e., \ (\ left.d \: \ Middle | \: \ GCD \ limits_. 1 = {I} ^ {m} cnt_i \ right \). . Then the formula becomes:

\[\begin{aligned}\mathbf{Ans}&=\sum_{k=2}^{n}\dfrac{1}{k}\sum_{d|k}\varphi(d)\cdot f\!\left(\dfrac{k}{d}\right)\!\\&=\sum_{k=2}^{n}\dfrac{1}{k}\sum_{d|k}\varphi(d)\cdot\!\left\{\!\left[d\:\middle|\:\gcd\limits_{i=1}^{m}cnt_i\right]\!\cdot\!\left[x^{n/d}\right]\!T^{k/d}\cdot\binom{n/d}{cnt_1/d,cnt_2/d,\ldots,cnt_m/d}\right\}\!\end{aligned}\]

At this point there are two paths, one is left behind generating function \ (T \) in the form of the same, and the second is to consider the nature of the number of Cattleya.

First use the first approach, consider switching the order of summation and change the summation index \ (k \) is \ (KD \) :

\[\begin{aligned}\mathbf{Ans}&=\sum_{k=2}^{n}\dfrac{1}{k}\sum_{d|k}\varphi(d)\cdot\!\left\{\!\left[d\:\middle|\:\gcd_{i=1}^{m}cnt_i\right]\!\cdot\!\left[x^{n/d}\right]\!T^{k/d}\cdot\binom{n/d}{cnt_1/d,cnt_2/d,\ldots,cnt_m/d}\right\}\!\\&=-t_n\binom{n}{cnt_{1\ldots m}}+\sum_{d\mid\gcd_{i=1}^{m}cnt_i}\varphi(d)\cdot\binom{n/d}{cnt_{1\ldots m}/d}\cdot\!\left[x^{n/d}\right]\!\sum_{k=1}^{n/d}\frac{T^k}{kd}\\&=-t_n\binom{n}{cnt_{1\ldots m}}+\sum_{d\mid\gcd_{i=1}^{m}cnt_i}\frac{\varphi(d)}{d}\cdot\binom{n/d}{cnt_{1\ldots m}/d}\cdot\!\left[x^{n/d}\right]\!\sum_{k=1}^{+\infty}\frac{T^k}{k}\\&=-t_n\binom{n}{cnt_{1\ldots m}}+\sum_{d\mid\gcd_{i=1}^{m}cnt_i}\frac{\varphi(d)}{d}\cdot\binom{n/d}{cnt_{1\ldots m}/d}\cdot\!\left[x^{n/d}\right]\!(-\ln(1-T))\end{aligned}\]

A second row behind the first because of the statistical \ (d = k = 1 \ ) case, but the actual need not, therefore to lose.
The last line using the \ (\ LN \) in \ (\ 1) deployed at a Taylor series: \ (\ DisplayStyle \ LN (X-1) = - \ sum_ I = {1} ^ {+ \ infty} \ X FRAC {I} {I} ^ \) .
Polynomial to calculate a logarithmic function - (\ ln (1-T ) \) \ can be directly calculated according to this formula. Time complexity \ (\ mathcal {O} (n-\ log n-+ \ sigma_0 (n-) \ CDOT m) \) .


The second approach is to consider the number and Cattleya own \ (m \) convolutions of \ (n-\) through the keys of the key.

Has the formula \ (\ [^ n-X] DisplayStyle C ^ m = \ Binom {2N + m-. 1} {n-} - \ Binom {2N + m-. 1} {n--. 1} \) , this formula is substituted into available too:

\[ \begin{aligned} \mathbf{Ans}&=\sum_{k=2}^{n}\dfrac{1}{k}\sum_{d|k}\varphi(d)\cdot\!\left\{\!\left[d\:\middle|\:\gcd\limits_{i=1}^{m}cnt_i\right]\!\cdot\!\left[x^{n/d}\right]\!T^{k/d}\cdot\binom{n/d}{cnt_1/d,cnt_2/d,\ldots,cnt_m/d}\right\}\!\\ &=\sum_{k=2}^{n}\dfrac{1}{k}\sum_{d|k}\varphi(d)\cdot\!\left\{\!\left[d\:\middle|\:\gcd\limits_{i=1}^{m}cnt_i\right]\!\cdot\!\left(\binom{2n/d-k/d-1}{2n/d-2k/d}-\binom{2n/d-k/d-1}{2n/d-2k/d-1}\right)\!\cdot\binom{n/d}{cnt_{1\ldots m}/d}\right\}\!\\ &=-t_n\binom{n}{cnt_{1\ldots m}}+\sum_{d\mid\gcd_{i=1}^{m}cnt_i}\varphi(d)\cdot\binom{n/d}{cnt_{1\ldots m}/d}\sum_{k=1}^{n/d}\!\left(\binom{2n/d-k-1}{2n/d-2k}-\binom{2n/d-k-1}{2n/d-2k-1}\right)\! \end{aligned} \]

Can be calculated directly, complexity \ (\ mathcal {O} (\ sigma_0 (n-) (n-m +)) \) .

Guess you like

Origin www.cnblogs.com/PinkRabbit/p/11525881.html