Binomial inversion and its application

concept

Binomial inversion inversion as a form, commonly used by "a specified number" seeking "just several" problem.

Note: Although formally binomial inversion and multi-step inclusion and exclusion are very similar, but they are not equivalent, but the habits are called multi-step inclusion and exclusion.

Introduced

Since the multi-step form and similar inclusion and exclusion, we talk from a multi-step inclusion and exclusion.

We all know: $ | A \ cup B | = | A | + | B | - | A \ cap B | $, this is in fact the inclusion-exclusion principle.

Its general form:

$$|A_1\cup A_2\cup...\cup A_n|=\sum\limits_{1\le i\le n}|A_i|-\sum\limits_{1\le i<j\le n}|A_i\cap A_j|+...+(-1)^{n-1}\times |A_1\cap A_2\cap ...\cap A_n|$$

prove:

An element is provided $ m $ sets included, then its contribution to the left of $ 1 to $;
Contribution to the right is $ \ sum \ limits_ {i = 1} ^ m (-1) ^ {i- 1} {m \ choose i} = - \ sum \ limits_ {i = 1} ^ m (-1) ^ i {m \ choose i} = 1- \ sum \ limits_ {i = 0} ^ m (-1 ) ^ i {m \ choose i } = 1- (1-1) ^ m = 1 $.

Therefore, the right side is equal to the left, proof.

form

In the form of zero

Just follow the formula of multi-step inclusion-exclusion, denoted $ A_i ^ c $ $ A_i $ express the complement, will be generally in the form of deformation can be obtained:
$$
| A_1 ^ c \ ^ c A_2 CAP \ CAP ... \ CAP A_n ^ c | = | S | - \ sum \ limits_ {1 \ le i \ le n} | A_i | + \ sum \ limits_ {1 \ le i <j \ le n} | A_i \ cap A_j | - .. . + (- 1) the n-^ \ Times | A_1 \ A_2 CAP \ CAP ... \ CAP A_n |
$$
Meanwhile, due to the complement of the complement of the original is set, so there are:
$$
| A_1 \ CAP A_2 \ cap ... \ cap A_n | = | S | - \ sum \ limits_ {1 \ le i \ le n} | A_i ^ c | + \ sum \ limits_ {1 \ le i <j \ le n} | A_i ^ C \ C ^ CAP A_j | -... + (-. 1) n-^ \ Times | A_1 C ^ \ ^ C A_2 CAP \ CAP ... \ C ^ CAP A_n |
$$
consider a special case: a plurality of only intersection size of the collection and the number of collections related.

Note $ f (n) $ $ intersection size represents a complement of the n-$, $ g (n) $ $ represents the size of the original set of n-th $, respectively, the two equations can be written:
$$
F (n-) = \ SUM \ limits_ = {0} ^ n-I (-1) ^ {n-I \ I} the Choose G (I) \
G (n-) = \ SUM \ limits_ = {0} ^ n-I (-1) ^ I { n-\ I} the Choose F (I)
$$
obviously these two formulas is an equivalence relation, it is derived mutual relationship, so we get a binomial form zero inversion:
$$
F (n-) = \ SUM \ limits_ {i = 0} ^ n (-1) ^ i {n \ choose i} g (i) \ Leftrightarrow g (n) = \ sum \ limits_ {i = 0} ^ n (-1) ^ i { n-\ I} the Choose F (I)
$$

In the form of a

公式如下:
$$
f(n)=\sum\limits_{i=0}^n{n\choose i}g(i)\Leftrightarrow g(n)=\sum\limits_{i=0}^n(-1)^{n-i}{n\choose i}f(i)
$$

A proof

In the form of zero, let $ h (n) = (- 1) ^ ng (n) $, the form becomes a zero:
$$
F (n-) = \ SUM \ limits_ I = {0} ^ {n-n- \ choose i} h (i) \ Leftrightarrow \ frac {h (n)} {(- 1) ^ n} = \ sum \ limits_ {i = 0} ^ n (-1) ^ i {n \ choose i} f (i)
$$
finishing is a form.

Proving that these two

The right side is substituted into the left, then:

$$
\begin{split}
f(n)&=\sum\limits_{i=0}^n{n\choose i}\sum\limits_{j=0}^i(-1)^{i-j}{i\choose j}f(j)\&=\sum\limits_{i=0}^n\sum\limits_{j=0}^i(-1)^{i-j}{n\choose i}{i\choose j}f(j)
\end{split}
$$

Consider order transposing two summation symbol, i.e. the first enumeration $ I $, $ J $ then enumerate, then another:
$$
F (n-) = \ SUM \ limits_ {J} = 0 ^ NF (J) \ SUM \ limits_ {J} = I n-^ (-1) ^ {} {ij of n-\ {I} the Choose I \ J} the Choose
$$
consider composition $ {n \ choose i} { i \ choose j} $ of significance: from $ n $ a $ i $ select one, and then selected from $ i $ a $ j $ th. May wish to turn to, start with $ n $ $ j $ a selected one, and then choose from the rest of the $ ij $ nj $ a in $, namely $ {n \ choose j} { nj \ choose ij} $.

You can then be obtained:
$$
\ Split the begin {}
F (n-) & = \ SUM \ limits_ {J} = 0 {n-n-^ \} the Choose F J (J) \ SUM \ limits_ I = J {} ^ {n- NJ \ the Choose ij of} (-. 1) ^ {ij of} \
& = \ SUM \ limits_ {J = 0} ^ n-{n-\ the Choose J} F (J) \ SUM \ limits_ {T = 0} ^ {NJ} NJ {\ the Choose T} (-. 1) ^ {^ T1 NJT} \
& = \ SUM \ limits_ {J} = 0 {n-n-^ \} the Choose F J (J) (1-1 of) NJ ^ {}
\ Split} {End
$$
when time $ 0 $ nj \ neq, apparently $ (1-1) ^ {nj} = 0 $;
as $ nj = 0 $ occurred while $ 0 $ 0 ^ can not be directly calculated, it is necessary to use a combination of solving form, this time $ {nj \ choose t} ( - 1) ^ {t} = 1 $.

Therefore $ \ sum \ limits_ {t = 0} ^ {nj} {nj \ choose t} (- 1) ^ t = [j = n] $, then:
$$
F (n-) = {n-\} n-the Choose F (n-) = F (n-)
$$
about identity, proof.

Note: Since the two are not used to prove I $ $ $ $ 0 from the beginning of this nature, the more general formula:
$$
F (n-) = \ SUM \ limits_ I = {n-m} ^ {n-\ I the Choose G} (I) \ Leftrightarrow G (n-) = \ SUM \ limits_} ^ {n-m I = (-1) n-^ {Ni} {\ I} the Choose F (I)
$$

In the form of two

This form and a form similar to the most commonly used formulas. Formula is as follows:
$$
F (n-) = \ SUM \ limits_ I = {n-m} ^ {I \} the Choose n-G (I) \ Leftrightarrow G (n-) = \ SUM \ limits_} ^ {n-m I = ( -1) ^ {} in {I \} the Choose n-F (I)
$$

prove

将右侧代入左侧,则:
$$
\begin{split}
f(n)&=\sum\limits_{i=n}^m{i\choose n}\sum\limits_{j=i}^m(-1)^{j-i}{j\choose i}f(j)\
&=\sum\limits_{i=n}^m\sum\limits_{j=i}^m(-1)^{j-i}{i\choose n}{j\choose i}f(j)\
&=\sum\limits_{j=n}^mf(j)\sum\limits_{i=n}^j(-1)^{j-i}{i\choose n}{j\choose i}\
&=\sum\limits_{j=n}^m{j\choose n}f(j)\sum\limits_{i=n}^j{j-n\choose j-i}(-1)^{j-i}\
&=\sum\limits_{j=n}^m{j\choose n}f(j)\sum\limits_{t=0}^{j-n}{j-n\choose t}(-1)^{t}1^{j-n-t}\
&=\sum\limits_{j=n}^m{j\choose n}f(j)(1-1)^{j-n}\
&=\sum\limits_{j=n}^m{j\choose n}f(j)[j=n]\
&={n\choose n}f(n)\
&=f(n)
\end{split}
$$

About identity, proof.

Clinical significance

Note $ f (n) $ indicates "Imperial selected from $ n-$ a", $ g (n) $ indicates "exactly selected from $ n-$ a", then for any $ i \ ge n $, $ g (i) $ in $ f (n) $ are calculated $ i \ choose n $ times, so $ f (n) = \ sum \ limits_ {i = n} ^ m {i \ choose n} g (i) $, where $ m $ is the upper bound number.

Note: in the definition, $ f (n) $ represents the first $ n $ th Imperial, Imperial is the case then count the number of programs, which will contain duplicate solution because a program can have a variety of handpicked situation. Specifically, just to select a $ I $, where Imperial digital $ i \ choose n $, so that g (i) in $ f (i) is calculated $ i \ choose n $ $ in times. Never $ f (n) $ be understood as normal and suffix.

example

[Bzoj2839] count set

Subject to the effect

Number of elements in a $ n-$ th element of the set has $ 2 n $ different subsets ^ (containing empty set), is now to be taken out at least one set in this $ 2 ^ n $ sets so that their intersection is $ k $, the program obtains the number of molding $ 10 $ ^ 9 + 7.

$ 1 \ n \ 10 ^ $ 6, $ 0 \ k \ le $ n.

answer

For people combinatorics slightly basic, easy to list intuition expression $ {n \ choose i} (2 ^ {2 ^ {ni}} - 1) $. I.e. Imperial $ I $ th intersection element, which contains a set $ I $ has $ 2 ^ {ni} $ a; Alternatively each set is optional, but can not not chosen, whereby this number of available programs.

Next, consider the relationship of Formula and are asking: Let $ f (i) $ denotes Imperial intersection element for a $ i $ a program number, $ g (i) $ represents the intersection of elements of exactly $ i embodiment of $ th , the $ {n \ choose k} (2 ^ {2 ^ {nk} -1}) = f (k) = \ sum \ limits_ {i = k} ^ n {n \ choose i} g (i) $ .

Binomial determined by inversion $ g (k) = \ sum \ limits_ {i = k} ^ n (-1) ^ {ik} {i \ choose k} f (i) = \ sum \ limits_ {i = k} ^ n (-1) ^ {ik} {i \ choose k} {n \ choose i} (2 ^ {2 ^ {ni}} - 1) $.

Some pre-processing means used, the time complexity $ O (n) $.

[Bzoj3622] I have nothing to be afraid of the

Subject to the effect

$ Are given two n-length sequences $ $ A $ and $ B $, $ 2N $ guarantee that the number of mutually different. To now $ A $ sequence number and $ B $ sequence number paired off seek "the number of $ A> B $ logarithm of the ratio of $ A <B $ plurality exactly $ K $" pairing scheme DAC 10 ^ 9 + 9 $ $.

answer

Obviously when $ NK $ odd necessarily no solution; when $ NK $ is an even number, $ A> logarithmic B $ is exactly $ \ frac {n + k} 2 $, denoted $ m = \ frac {n + k} 2 $.

Because of "just" is not easy to deal with this limitation, consider converting it into "King James" limit, and then processed by the binomial inversion.

First $ A $ and $ B $ in ascending order, set $ dp (i, j) $ $ considered shows a front $ A $ I $ the number of the Imperial scheme $ J $ $ A> B $ of number.

$ $ Pair A_i discussed case: if the pairing, the number of programs $ dp (i-1, j) $; if paired, referred to in less than $ B $ $ $ A_i number is the number of $ cnt (i ) $, then the program number $ dp (i-1, j-1) \ times (cnt (i) - (j-1)) $.

故 $dp(i,j)=dp(i-1,j)+dp(i-1,j-1)\times(cnt(i)-(j-1))$ 。

Provided $ f (i) $ denotes Imperial number $ I $ scheme $ A> B $ a, $ g (i) $ represents just $ I $ number scheme $ A> B $, then $ (nm)! \ times dp (n, m) = f (m) = \ sum \ limits_ {i = m} ^ n {i \ choose m} g (i) $.

故 $g(m)=\sum\limits_{i=m}^n(-1)^{i-m}{i\choose m}f(i)=\sum\limits_{i=m}^n(-1)^{i-m}{i\choose m}(n-i)!\times dp(n,i)$ 。

Time complexity $ O (n ^ 2) $.

[Bzoj4710] Specialty minutes

Subject to the effect

There are n-$ $ $ m $ species and individual articles, the kinds of goods there $ $ I $ $ a_i months, there is no distinction between different kinds of goods. To these items are now given to these people, so that each person assigned to the at least one article, for Evaluating the D ^ $ 10 $ 9 + 7.

answer

In the case of multiple items, "Everyone assigned to at least one article" is a very tricky conditions, consider converting it into "exactly $ 0 $ is not assigned to individual items," and with a binomial inversion to solve.

Provided $ f (i) $ denotes the number of Imperial $ I $ not assigned individual program item, $ g (i) $ represents the number of individual program just $ I $ items not assigned, then $ f (t) $ in , $ I $ species for the first article, when assigning equivalent a_i $ $ $ give the article a personal NT $ program number $ {nt + a_i-1 \ choose a_i-1} $, then $ {n \ choose t} \ prod \ limits_ {i = 1} ^ m {n-t + a_i-1 \ choose a_i-1} = f (t) = \ sum \ limits_ {i = t} ^ n {i \ choose t } g (i) $.

故 $g(t)=\sum\limits_{i=t}^n(-1)^{i-t}{i\choose t}f(i)=\sum\limits_{i=t}^n(-1)^{i-t}{i\choose t}{n\choose i}\prod\limits_{j=1}^m{n-i+a_j-1\choose a_j-1}$ 。

Final answer $ g (0) = \ sum \ limits_ {i = 0} ^ n (-1) ^ i {n \ choose i} \ prod \ limits_ {j = 1} ^ m n-i {+ a_j- 1 \ choose a_j-1} $.

Time complexity $ O (n ^ 2 + nm) $.

Guess you like

Origin www.cnblogs.com/GXZlegend/p/11407185.html