当前位置:网站首页>[combinatorics] non descending path problem (number of non descending paths with constraints)
[combinatorics] non descending path problem (number of non descending paths with constraints)
2022-07-03 16:30:00 【Programmer community】
One 、 The number of non descending paths of the constraint
from
(
0
,
0
)
(0,0)
(0,0) To
(
n
,
n
)
(n,n)
(n,n) Except endpoint , The number of non descending paths that do not touch the diagonal ?
At this time, the basic formula cannot be used for processing , You must use the idea of combining correspondence ;
In the example above , from
(
0
,
0
)
(0,0)
(0,0) Set out to
(
n
,
n
)
(n,n)
(n,n) , There are only two endpoints
(
0
,
0
)
(0,0)
(0,0) and
(
n
,
n
)
(n,n)
(n,n) Touching the diagonal , Every step in the middle does not touch the diagonal ;
1 . Calculation principle , First calculate the non descending path below the diagonal : Here, only the number of non descending paths below the diagonal is counted , because The non descending path above and below the diagonal is symmetric , So here First calculate the non descending path below the diagonal ;
The non descending path below the diagonal multiply
2
2
2 , That's all Not touching the diagonal Number of non descending paths ;
2 . Starting point analysis : from
(
0
,
0
)
(0,0)
(0,0) After departure , The first
1
1
1 Step must go to the right , Go to the
(
1
,
0
)
(1, 0)
(1,0) spot , If you go up, you can't come down anymore ( Otherwise, it will touch the diagonal ) , At this time, it is not the non descending path below the diagonal ;
3 . End point analysis :
arrive
(
n
,
n
)
(n,n)
(n,n) spot , There are only two cases :
- Above the diagonal : One case is from the left
(
n
−
1
,
n
)
(n-1 , n)
(n−1,n) To the right
(
n
,
n
)
(n,n)
(n,n) spot , The path is above the diagonal ;
- Below the diagonal : One situation is from the bottom
(
n
,
n
−
1
)
(n , n-1)
(n,n−1) To the top
(
n
,
n
)
(n,n)
(n,n) spot , The path is below the diagonal ;
At present, only The number of non descending paths below the diagonal , arrive
(
n
,
n
)
(n,n)
(n,n) The previous step , Must be from
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Position go to
(
n
,
n
)
(n,n)
(n,n) Of ;
4 . Corresponding relation
Above You must leave after the starting point
(
1
,
0
)
(1, 0)
(1,0) spot , You must go before the end
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) spot ,
therefore Below the diagonal from
(
0
,
0
)
(0,0)
(0,0) To
(
n
,
n
)
(n,n)
(n,n) Except endpoint , The number of non descending paths that do not touch the diagonal
Equivalent to
from
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Except endpoint , The number of non descending paths that do not touch the diagonal
5 . Calculation
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Except endpoint , The number of non descending paths that do not touch the diagonal
Let's talk about “ from
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Except endpoint , The number of non descending paths that do not touch the diagonal ” How to count ;
Think in reverse , Statistics from
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Between , The non descending path that touches the diagonal , The rest is the path that does not touch the diagonal ;
The total of the above two is
C
(
2
n
−
2
,
n
−
1
)
C(2n-2 , n-1)
C(2n−2,n−1) individual ;
Above, One “ from
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) , The non descending path that touches the diagonal ” ,
In the picture Red dot
A
A
A Is the position where the non descending path finally contacts the diagonal , The front may touch the diagonal many times ;
take
(
1
,
0
)
(1, 0)
(1,0) spot And
A
A
A spot Blue line segment between , Make a symmetrical image about the diagonal , obtain Red line ,
In the picture above Blue line segment The starting point is
(
1
,
0
)
(1,0)
(1,0), So the corresponding The starting point of the red line segment must be
(
0
,
1
)
(0,1)
(0,1) ;
Every one from
(
1
,
0
)
(1,0)
(1,0) Start to
(
n
,
n
−
1
)
(n, n-1)
(n,n−1) The non descending path of the contact diagonal , There are blue line segments , Can use symmetrical method , Get one from
(
0
,
1
)
(0,1)
(0,1) arrive
A
A
A The red line segment of the dot ;
Here we get a combinatorial correspondence :
Each from
(
0
,
1
)
(0,1)
(0,1) set out , To
(
n
,
n
−
1
)
(n, n-1)
(n,n−1) Of Non descending path ( the Red line segment And remainder Black line segment Paths that can be spliced )
Can and
from
(
1
,
0
)
(1,0)
(1,0) set out , To
(
n
,
n
−
1
)
(n, n-1)
(n,n−1) Contact diagonal Non descending path
One-to-one correspondence ;
So if required " from
(
1
,
0
)
(1,0)
(1,0) set out , To
(
n
,
n
−
1
)
(n, n-1)
(n,n−1) Contact diagonal Number of non descending paths " , You can ask for “ from
(
0
,
1
)
(0,1)
(0,1) set out , To
(
n
,
n
−
1
)
(n, n-1)
(n,n−1) Of Number of non descending paths ” ;
“ from
(
0
,
1
)
(0,1)
(0,1) set out , To
(
n
,
n
−
1
)
(n, n-1)
(n,n−1) Of Number of non descending paths ” You can use formulas to calculate , The result is
C
(
2
n
−
2
,
n
)
C(2n - 2 , n)
C(2n−2,n) ,
Corresponding " from
(
1
,
0
)
(1,0)
(1,0) set out , To
(
n
,
n
−
1
)
(n, n-1)
(n,n−1) Contact diagonal Number of non descending paths " , The result is
C
(
2
n
−
2
,
n
)
C(2n - 2 , n)
C(2n−2,n) ;
6 . Calculation
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) The number of all non descending paths
Calculate according to the formula , The result is :
C
(
2
n
−
2
,
n
−
1
)
C(2n - 2 , n-1)
C(2n−2,n−1)
7 . Calculation
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Except endpoint , The number of non descending paths that do not touch the diagonal
"
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Except endpoint , The number of non descending paths that do not touch the diagonal " Namely
"
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) The number of all non descending paths " subtract "
(
1
,
0
)
(1, 0)
(1,0) To
(
n
,
n
−
1
)
(n,n-1)
(n,n−1) Except endpoint , The number of non descending paths that do not touch the diagonal " ;
C
(
2
n
−
2
,
n
−
1
)
−
C
(
2
n
−
2
,
n
)
\ \ \ \ C(2n - 2 , n-1) - C(2n - 2 , n)
C(2n−2,n−1)−C(2n−2,n)
=
(
2
n
−
2
n
−
1
)
−
(
2
n
−
2
n
)
=\dbinom{2n - 2}{n-1} - \dbinom{2n - 2}{n}
=(n−12n−2)−(n2n−2)
8 . Calculation from
(
0
,
0
)
(0,0)
(0,0) To
(
n
,
n
)
(n,n)
(n,n) Except endpoint , The number of non descending paths that do not touch the diagonal
above
(
2
n
−
2
n
−
1
)
−
(
2
n
−
2
n
)
\dbinom{2n - 2}{n-1} - \dbinom{2n - 2}{n}
(n−12n−2)−(n2n−2) It only calculates the number of non descending paths below the diagonal ,
from
(
0
,
0
)
(0,0)
(0,0) set out , To
(
n
,
n
)
(n,n)
(n,n) The number of non descending paths that do not touch the diagonal , Multiplied by
2
2
2 , You get the final result of this topic ;
from
(
0
,
0
)
(0,0)
(0,0) To
(
n
,
n
)
(n,n)
(n,n) Except endpoint , The number of non descending paths that do not touch the diagonal
The end result is :
2
[
(
2
n
−
2
n
−
1
)
−
(
2
n
−
2
n
)
]
2[\dbinom{2n - 2}{n-1} - \dbinom{2n - 2}{n}]
2[(n−12n−2)−(n2n−2)]
边栏推荐
- Multithread 02 thread join
- Extraction of the same pointcut
- 在ntpdate同步时间的时候出现“the NTP socket is in use, exiting”
- Colab works with Google cloud disk
- EditText request focus - EditText request focus
- [combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
- MongoDB 的安装和基本操作
- Golang anonymous function use
- How programming apes grow rapidly
- 特征多项式与常系数齐次线性递推
猜你喜欢
Record a jar package conflict resolution process
Mysql 将逗号隔开的属性字段数据由列转行
消息队列消息丢失和消息重复发送的处理策略
From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
面试官:JVM如何分配和回收堆外内存
Stm32f103c8t6 firmware library lighting
Zebras are recognized as dogs, and Stanford found the reason why AI made mistakes
2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
There are several APIs of airtest and poco that are easy to use wrong in "super". See if you have encountered them
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
随机推荐
(Supplement) double pointer topic
MongoDB 的安装和基本操作
Cocos Creator 2. X automatic packaging (build + compile)
面试官:JVM如何分配和回收堆外内存
[web security] - [SQL injection] - error detection injection
[combinatorics] non descending path problem (outline of non descending path problem | basic model of non descending path problem | non descending path problem expansion model 1 non origin starting poi
Golang 装饰器模式以及在NSQ中的使用
8个酷炫可视化图表,快速写出老板爱看的可视化分析报告
SVN使用规范
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
EditText request focus - EditText request focus
香港理工大学|数据高效的强化学习和网络流量动态的自适应最优周界控制
一台服务器最大并发 tcp 连接数多少?65535?
Expression of request header in different countries and languages
Hibernate的缓存机制/会话级缓存机制
Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
初试scikit-learn库
Characteristic polynomial and constant coefficient homogeneous linear recurrence
A survey of state of the art on visual slam