package middle; import java.io.BufferedInputStream; import java.math.BigInteger; import java.util.Scanner; /** * 令h(0)=1,h(1)=1,catalan数满足递归式: * h(n)= h(0)*h(n-1) + h(1)*h(n-2) + ... + h(n-1)h(0) (其中n>=2),这是n阶递推关系; * 还可以化简为1阶递推关系: 如h(n)=(4n-2)/(n+1)*h(n-1)(n>1) h(0)=1 * 该递推关系的解为:h(n)=c(2n,n)/(n+1) (n=1,2,3,...)//2n!/n!/n! * 卡 塔兰数例的前几项为(sequence A000108 in OEIS) [注: n = 0, 1, 2, 3, … n] * 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, * 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, * 91482563640, 343059613650, 1289904147324, 4861946401452, … * poj2084 * @author NC */ public class Poj2084 { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); while (scan.hasNext()) { BigInteger n = scan.nextBigInteger(); if (n.compareTo(BigInteger.ZERO) == -1) { break; } BigInteger ss = BigInteger.ONE; BigInteger c = BigInteger.ONE; BigInteger s = null ; for (int i = 1; i <= 2 * n.intValue(); i++) { ss = ss.multiply(c); c=c.add(BigInteger.ONE); if(i==n.intValue()){ s = ss; } } System.out.println(ss.divide(s).divide(s).divide(n.add(BigInteger.ONE))); } } }