当前位置:网站首页>[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)]
边栏推荐
- 8个酷炫可视化图表,快速写出老板爱看的可视化分析报告
- 一台服务器最大并发 tcp 连接数多少?65535?
- Client does not support authentication protocol requested by server; consider upgrading MySQL client
- [proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
- Pointcut expression
- 用同花顺炒股开户安全吗?
- Leetcode binary search tree
- Remote file contains actual operation
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- Extraction of the same pointcut
猜你喜欢

消息队列消息丢失和消息重复发送的处理策略

Basis of target detection (IOU)

A survey of state of the art on visual slam

Record a jar package conflict resolution process
![[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix](/img/d6/3c21c25f1c750f17aeb871124e80f4.png)
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix

Add color to the interface automation test framework and realize the enterprise wechat test report

Record windows10 installation tensorflow-gpu2.4.0

2022爱分析· 国央企数字化厂商全景报告

Getting started with Message Oriented Middleware
![[web security] - [SQL injection] - error detection injection](/img/18/5c511871dab0e5c684b6b4c081c061.jpg)
[web security] - [SQL injection] - error detection injection
随机推荐
[combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN
Page dynamics [2]keyframes
8 tips for effective performance evaluation
[web security] - [SQL injection] - error detection injection
Initial test of scikit learn Library
架构实战营 - 第 6 期 毕业总结
QT serial port UI design and solution to display Chinese garbled code
PHP secondary domain name session sharing scheme
[combinatorics] summary of combinatorial identities (eleven combinatorial identities | proof methods of combinatorial identities | summation methods)*
线程池执行定时任务
特征多项式与常系数齐次线性递推
Effect of ARP package on FTP dump under vxworks-6.6 system
Interviewer: how does the JVM allocate and recycle off heap memory
高等数学(第七版)同济大学 习题2-1 个人解答
Hibernate的缓存机制/会话级缓存机制
Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
Cocos Creator 2. X automatic packaging (build + compile)
无心剑中译泰戈尔《漂鸟集(1~10)》
(补)双指针专题