默慈金数

 今天,我来讲一种比较特殊的数,可能很多人都没有听过这种数,它叫默慈金数。但事实是它早就已经进入了ACM竞

赛中了。好了,接下来让我们一起来认识它,并会讲述一些它的重要应用。

本文转自ACdreamer博客(ACdreamer大牛太牛了)

百度百科上,是这样定义默慈金数的:一个给定的数的默慈金数是在一个圆上的个点间,画出彼此不相交弦的

全部方法的总数。比如4时,方法数为9,如下图

                    

默慈金数在几何,组合数学和数论等领域中皆有其重要用途,它的递归定义如下

      

接下来是最重要的环节,来探讨上述递推公式的由来。有一篇论文有详细讲解,我已放到豆丁网上,如下

链接:http://www.docin.com/p1-964777006.html

其实默慈金数还有很多不同的展现方式,比如:在一个网格上,若限定每步只能向右移动一格,可以右上,右下,

横向,向右,并禁止移动到以下的地方,则以这种走法移动步从的可能形成的路径的总数

的默慈金数。如下图示

      

接下来,看几个比较典型的题目。

题目:http://acm.hdu.edu.cn/showproblem.php?pid=3723

分析:赤裸裸的求默慈金数,用Java处理大数比较方便。实际上默慈金数还有另一个公式,如下

      

     对于本题,我们枚举有步向上,那么必然有步向下,则针对每个得到答案是,求和

     后便得到最终答案。

import java.math.*;

import java.util.*;

public class Main {

public static final int N = 10005;

public static final BigInteger MOD = BigInteger.valueOf(10).pow(100);

public static BigInteger ans[] = new BigInteger[N];

public static void Init(){

ans[1] = BigInteger.valueOf(1);

ans[2] = BigInteger.valueOf(2);

for(int i = 3; i < N; i++){

BigInteger a = ans[i - 1].multiply((BigInteger.valueOf(2).multiply(BigInteger.valueOf(i)).add(BigInteger.valueOf(1))));

BigInteger b = ans[i - 2].multiply((BigInteger.valueOf(3).multiply(BigInteger.valueOf(i)).subtract(BigInteger.valueOf(3))));

ans[i] = (a.add(b)).divide(BigInteger.valueOf(i).add((BigInteger.valueOf(2))));

}

}

public static void main(String[] args){

Init();

Scanner cin = new Scanner(System.in);

while(cin.hasNext()){

int n = cin.nextInt();

System.out.println(ans[n].mod(MOD));

}

}

}

题目:http://acdream.info/problem?pid=1667

分析:数一巨巨的题目,仔细想想实际跟上题一样,直接上默慈金数即可。

默慈金数的生成函数详见:http://mathworld.wolfram.com/MotzkinNumber.html

讲完了默慈金数,还有一类数,叫做那罗延数,具体参考如下链接

链接:http://en.wikipedia.org/wiki/Narayana_number 

原文地址:https://www.cnblogs.com/boson-is-god/p/5431810.html