寻找这个二元递推方程的公式? F(M,N)= F(M-1,N)+ F(M,N-1)方程、公式

2023-09-11 03:28:09 作者:我的心脏你的模样

对不起你们!我的错!谢谢你的提醒,我发现F(0,K)== F(K,0)== 1。这个问题是关于如何计算从电网(0,0)的最短路径(M数,N )。

我要解决下面的公式,现在,搞清楚F(M,N)等于。

I have to solve the following equation now, find out exactly what f(m,n) equal to.

1) f(m,n) = 0 : when (m,n) = (0,0)
**2) f(m,n) = 1 : when f(0,k) or f(k,0)**
3) f(m,n) = f(m-1,n) + f(m,n-1) : when else

例如:

1) f(0,0) = 0; 
2) f(0,1) = 1; f(2,0) = 1; 
3) f(2,1) = f(1,1) + f(2,0) = f(0, 1) + f(1, 0) + f(2, 0) = 1 + 1 + 1 = 3  

我记得有解决这种类型的二进制递推方程正如我在算法类几年以前就学会一种标准的方式,但我不记得了。

I remember there is a standard way to solve such kinds of binary recurrence equation as I learned in my algorithm class several years ago, but I just cannot remember for now.

谁能给出任何提示?或关键字如何找到答案?

Could anyone give any hint? Or a keyword how to find the answer?

推荐答案

唉,我当时只是觉得好玩通过我的旧课本上生成函数,你去了,又变的问题!

Ugh, I was just having fun going through my old textbooks on generating functions, and you went and changed the question again!

这个问题是关于如何计算的网格(0,0)的最短路径的数量(M,N)。

This question is about how to count the number of shortest path from grid (0,0) to (m,n).

这是一个基本的组合数学问题 - 它不需要知道有关生成功能,甚至复发的关系什么

This is a basic combinatorics question - it doesn't require knowing anything about generating functions, or even recurrence relations.

要解决的,想象的路径被写了当U的序列(针对上)和R的(适用于权利)。如果我们从(0,0)移动,比方说,(5,8),必须有5个R的和8Ù的。仅举一例:

To solve, imagine the paths being written out as a sequence of U's (for "up") and R's (for "right"). If we are moving from (0,0) to, say, (5, 8), there must be 5 R's and 8 U's. Just one example:

RRUURURUUURUU

总是会有,在这个例子中,8Ú的和5个R的;不同的路径,只会让他们在不同的订单。因此,我们可以只选择8个位置为ü的,其余的必须为R的。因此,答案是

There will always be, in this example, 8 U's and 5 R's; different paths will just have them in different orders. So we can just choose 8 positions for our U's, and the rest must be R's. Thus, the answer is

(8+5) choose (8)

或者,在一般情况下,

Or, in general,

(m+n) choose (m)