当前位置:网站首页>[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 )
边栏推荐
- A. Berland Poker &1000【简单数学思维】
- 2022-2028 global petroleum pipe joint industry research and trend analysis report
- Summary and Reflection on the third week of winter vacation
- A. Berland Poker & 1000 [simple mathematical thinking]
- Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
- Coordinate layer conversion tool (video)
- Count the number of pixel values in the image
- 2022-2028 global lithium battery copper foil industry research and trend analysis report
- G1 garbage collector of garbage collector
- MySQL duplicate check
猜你喜欢

The second largest gay dating website in the world was exposed, and the status of programmers in 2022

Have you learned the correct expression posture of programmers on Valentine's day?

After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people

SQL injection -day16

Valentine's day, send you a little red flower~

2022-2028 global plasmid DNA cdmo industry research and trend analysis report
![Bloom filter [proposed by bloom in 1970; redis cache penetration solution]](/img/f9/27a75454b464d59b9b3465d25fe070.jpg)
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]

English語法_名詞 - 分類

Naoqi robot summary 27

Why can deeplab v3+ be a God? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
随机推荐
SDNUOJ1015
[Tongxin UOS] scanner device management driver installation
Sensor 调试流程
Nodejs (01) - introductory tutorial
[linux]centos 7 reports an error when installing MySQL "no package MySQL server available" no package ZABBIX server MySQL available
What problems can cross-border e-commerce sellers solve with multi platform ERP management system
A. Odd Selection【BruteForce】
Line by line explanation of yolox source code of anchor free series network (5) -- mosaic data enhancement and mathematical understanding
Administrative division code acquisition
Niuke monthly race 31 minus integer
Valentine's day, send you a little red flower~
Codeforces Round #803 (Div. 2) C. 3SUM Closure
Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
AcWing 271. Teacher Yang's photographic arrangement [multidimensional DP]
Redis on local access server
AcWing 271. 杨老师的照相排列【多维DP】
Setinterval CPU intensive- Is setInterval CPU intensive?
189. Rotation array
PHP MySQL preprocessing statement
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)