当前位置:网站首页>[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
2022-07-03 18:30:00 【Programmer community】
List of articles
- One 、 Wrong way
- Two 、 Derivation of recurrence formula for staggered arrangement problem
- 3、 ... and 、 Derive the staggered formula
One 、 Wrong way
n
n
n A different letter And
n
n
n Different envelopes , take
n
n
n The number of schemes with wrong envelopes in each letter ;
Dislocation ( Derangement ) , Therefore, we use
D
(
n
)
D(n)
D(n) Express
n
n
n Staggered arrangement of elements ;
If there is
1
1
1 letter ,
n
=
1
n= 1
n=1 , At this time, it is not allowed to arrange wrongly ,
D
(
1
)
=
0
D(1) = 0
D(1)=0 ;
If there is
2
2
2 letter ,
n
=
2
n= 2
n=2 , At this time, the wrong arrangement can be completed by exchanging , Yes
1
1
1 Kind of plan ,
D
(
2
)
=
1
D(2) = 1
D(2)=1 ;

If there is
3
3
3 letter ,
1
,
2
,
3
1,2,3
1,2,3 Three letters and three envelopes ,
- If
1
1
1 Put it in
3
3
3 In the envelope , At this time will be
2
2
2 Put it in
1
1
1 In the envelope , take
3
3
3 Put it in
2
2
2 In the envelope ,
1
,
2
,
3
1,2,3
1,2,3
3
,
1
,
2
3,1,2
3,1,2
- If
1
1
1 Put it in
2
2
2 In the envelope , At this time will be
2
2
2 Put it in
3
3
3 In the envelope , take
3
3
3 Put it in
1
1
1 In the envelope ,
1
,
2
,
3
1,2,3
1,2,3
2
,
3
,
1
2,3,1
2,3,1
D
(
3
)
=
2
D(3) = 2
D(3)=2
If there is
4
4
4 letter , At this time, it is difficult to calculate ,
9
9
9 Methods ,
D
(
4
)
=
9
D(4) = 9
D(4)=9
If there is
5
5
5 letter
⋯
\cdots
⋯ ,
D
(
5
)
=
44
D(5) = 44
D(5)=44
⋮
\vdots
⋮
If there is
n
n
n letter
⋯
\cdots
⋯ ,
D
(
n
)
=
n
!
(
(
−
1
)
0
0
!
+
(
−
1
)
1
1
!
+
(
−
1
)
2
2
!
+
(
−
1
)
3
3
!
+
⋯
+
(
−
1
)
n
n
!
)
=
n
!
∑
k
=
0
n
(
−
1
)
k
k
!
D(n) = n! ( \cfrac{(-1)^0}{0!} + \cfrac{(-1)^1}{1!} + \cfrac{(-1)^2}{2!} + \cfrac{(-1)^3}{3!} + \cdots + \cfrac{(-1)^n}{n!} ) = n! \sum\limits_{k=0}^{n}\cfrac{(-1)^k}{k!}
D(n)=n!(0!(−1)0+1!(−1)1+2!(−1)2+3!(−1)3+⋯+n!(−1)n)=n!k=0∑nk!(−1)k
Two 、 Derivation of recurrence formula for staggered arrangement problem
Observe the above rules , Derive the recurrence formula ;
If there is
n
n
n letter , Any letter needs to be misplaced , The number of staggered schemes is
D
(
n
)
D(n)
D(n) ;
1 . Step by step counting principle : Use Step by step counting principle , Statistics first The arrangement of the first letter , And then we'll talk about it The number of arrangement methods of other letters ;
( 1 ) First step : First find a letter
a
a
a come out , This letter cannot be placed in its own place , Can only be placed in the rest
n
−
1
n-1
n−1 In a position , So there is
n
−
1
n-1
n−1 To arrange ;
( 2 ) The second step : Now let's talk about the rest except
a
a
a The wrong arrangement of the position of other letters except ;
2 . Classification and counting principle
Suppose the first letter
a
a
a Occupy
b
b
b The location of , So at this time
b
b
b There are two ways to put it in which envelope ,
b
b
b Put it in
a
a
a Location , or
b
b
b Not put in
a
a
a Location ;
( 1 ) The first category : The first is to put
a
a
a Location , here
b
b
b Put it in
a
a
a Location , be left over
n
−
2
n-2
n−2 The letter is wrongly arranged , The number of options is
D
(
n
−
2
)
D(n-2)
D(n−2)
( 2 ) The second category : The second situation is
b
b
b I didn't go
a
a
a The location of , that
b
b
b May appear in addition to
a
a
a Anywhere except ,
b
b
b Yes
n
−
2
n-2
n−2 There are four places to go , Can't go to
a
,
b
a,b
a,b Location , All other elements have
n
−
2
n-2
n−2 There are four places to go (
a
,
b
a,b
a,b Position cannot go ) , In this case It's equivalent to dividing
a
a
a The wrong arrangement of other elements besides , namely
n
−
1
n-1
n−1 Dislocation of elements , The number of options is
D
(
n
−
1
)
D(n-1)
D(n−1) ; * ( Core derivation logic ) *
( 3 ) The law of addition : Summarize the above classification and counting principles , Use The law of addition , The result is
D
(
n
−
1
)
+
D
(
n
−
2
)
D(n -1) + D(n-2)
D(n−1)+D(n−2)
3 . product rule : Summarize the above step-by-step counting principle , Use product rule , The result is
D
(
n
)
=
(
n
−
1
)
(
D
(
n
−
1
)
+
D
(
n
−
2
)
)
D(n) = (n-1) (D(n -1) + D(n-2))
D(n)=(n−1)(D(n−1)+D(n−2))
3、 ... and 、 Derive the staggered formula
The recursive formula :
D
(
n
)
=
(
n
−
1
)
(
D
(
n
−
1
)
+
D
(
n
−
2
)
)
D(n) = (n-1) (D(n -1) + D(n-2))
D(n)=(n−1)(D(n−1)+D(n−2))
initial value :
D
(
1
)
=
0
,
D
(
2
)
=
1
D(1) = 0 , D(2) = 1
D(1)=0,D(2)=1
Use Recurrence equation , Generating functions to solve recursive equations , Principle of tolerance and exclusion , The following formula can be derived :
D
(
n
)
=
n
!
(
(
−
1
)
0
0
!
+
(
−
1
)
1
1
!
+
(
−
1
)
2
2
!
+
(
−
1
)
3
3
!
+
⋯
+
(
−
1
)
n
n
!
)
=
n
!
∑
k
=
0
n
(
−
1
)
k
k
!
D(n) = n! ( \cfrac{(-1)^0}{0!} + \cfrac{(-1)^1}{1!} + \cfrac{(-1)^2}{2!} + \cfrac{(-1)^3}{3!} + \cdots + \cfrac{(-1)^n}{n!} ) = n! \sum\limits_{k=0}^{n}\cfrac{(-1)^k}{k!}
D(n)=n!(0!(−1)0+1!(−1)1+2!(−1)2+3!(−1)3+⋯+n!(−1)n)=n!k=0∑nk!(−1)k
Reference resources :
- Baidu Encyclopedia - The staggered formula
- 【 Combinatorial mathematics 】 Recurrence equation ( Summary of the solution process of recursive equations | Homogeneous | Heavy root | Nonhomogeneous | The characteristic root is 1 | Exponential form | The bottom is the exponential form of the characteristic root ) **
- 【 Combinatorial mathematics 】 Generating function ( Generate function application scenarios | Solving recursive equations using generating functions )
- 【 Set theory 】 Principle of tolerance and exclusion ( The inclusion exclusion principle | Example )
边栏推荐
- Theoretical description of linear equations and summary of methods for solving linear equations by eigen
- On Data Mining
- Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
- [combinatorics] generating function (example of using generating function to solve the number of solutions of indefinite equation)
- Prototype inheritance..
- Administrative division code acquisition
- Computer graduation design PHP makeup sales Beauty shopping mall
- Solve the problem of inaccurate network traffic monitored by ZABBIX with SNMP
- Nodejs (01) - introductory tutorial
- A. Odd Selection【BruteForce】
猜你喜欢

How to track the real-time trend of Bank of London

Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries

How to expand the capacity of golang slice slice

English语法_名词 - 分类

English語法_名詞 - 分類
![Golang string (string) and byte array ([]byte) are converted to each other](/img/41/20f445ef9de4adf2a2aa97828cb67f.jpg)
Golang string (string) and byte array ([]byte) are converted to each other

The vscode code is automatically modified to a compliance code when it is formatted and saved

Redis core technology and practice - learning notes (11): why not just string

2022-2028 global solid phase extraction column industry research and trend analysis report

Valentine's day, send you a little red flower~
随机推荐
Supervisor monitors gearman tasks
2022-2028 global marking ink industry research and trend analysis report
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
Self executing function
Setinterval CPU intensive- Is setInterval CPU intensive?
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
SSL / bio pour OpenSSL Get FD
企业级自定义表单引擎解决方案(十二)--表单规则引擎2
[combinatorics] generating function (positive integer splitting | repeated ordered splitting | non repeated ordered splitting | proof of the number of repeated ordered splitting schemes)
The second largest gay dating website in the world was exposed, and the status of programmers in 2022
2022-2028 global petroleum pipe joint industry research and trend analysis report
Codeforces Round #803 (Div. 2) C. 3SUM Closure
PHP MySQL where clause
English语法_名词 - 分类
204. Count prime
图像24位深度转8位深度
[combinatorics] exponential generating function (properties of exponential generating function | exponential generating function solving multiple set arrangement)
Naoqi robot summary 27
The number of incremental paths in the grid graph [dfs reverse path + memory dfs]
Redis core technology and practice - learning notes (IX): slicing cluster