当前位置:网站首页>[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)]
边栏推荐
- Expression of request header in different countries and languages
- Cocos Creator 2. X automatic packaging (build + compile)
- What is the maximum number of concurrent TCP connections for a server? 65535?
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
- [combinatorics] combinatorial identity (sum of combinatorial identity products 1 | sum of products 1 proof | sum of combinatorial identity products 2 | sum of products 2 proof)
- 程序猿如何快速成长
- 8 tips for effective performance evaluation
- nifi从入门到实战(保姆级教程)——flow
- Top k questions of interview
- TCP congestion control details | 3 design space
猜你喜欢

TCP擁塞控制詳解 | 3. 設計空間

Mixlab编辑团队招募队友啦~~

Record a jar package conflict resolution process

斑馬識別成狗,AI犯錯的原因被斯坦福找到了

Détails du contrôle de la congestion TCP | 3. Espace de conception

QT串口ui设计和解决显示中文乱码

关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM

Mysql 将逗号隔开的属性字段数据由列转行

Netease UI automation test exploration: airtest+poco

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
随机推荐
Golang 装饰器模式以及在NSQ中的使用
程序猿如何快速成长
Is it safe to open a stock account by mobile registration? Does it need money to open an account
What is the maximum number of concurrent TCP connections for a server? 65535?
2022爱分析· 国央企数字化厂商全景报告
疫情常态化大背景下,关于远程办公的思考|社区征文
[combinatorics] combinatorial identity (sum of combinatorial identity products 1 | sum of products 1 proof | sum of combinatorial identity products 2 | sum of products 2 proof)
Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
爱可可AI前沿推介(7.3)
消息队列消息丢失和消息重复发送的处理策略
Unreal_DataTable 实现Id自增与设置RowName
ThreeJS 第二篇:顶点概念、几何体结构
8 tips for effective performance evaluation
深入理解 SQL 中的 Grouping Sets 语句
8个酷炫可视化图表,快速写出老板爱看的可视化分析报告
Top k questions of interview
Pointcut expression
Chinese translation of Tagore's floating birds (1~10)
架构实战营 - 第 6 期 毕业总结
关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM