大数卡特兰数
来源:互联网 发布:微博淘宝客封号 编辑:程序博客网 时间:2024/04/30 04:01
关于卡特兰数的介绍:http://baike.baidu.com/link?url=ClVyY47KI51GLOK4wJjghAPe0iNHgrgb4zUxrwO1SKGHZXsCR9Ftnhb7driZ8dQmT6mRSQW4BgYbUUvLGIWlR_
在这儿主要讲解怎样求比较大的卡特兰数,不能直接求,只能用到高精度的思想来求
HDU1023 1130 1134
可做模板
#include<iostream>#include<cmath>#include<algorithm>#include<cstdio>using namespace std;int a[101][101];int b[101];void Catanlan(){ int len; int cover; int temp; a[1][0]=b[1]=1;//先处理1 len=1; for(int i=2;i<101;i++) //卡特兰数的公式 { for(int j=0;j<len;j++) a[i][j]=a[i-1][j]*(4*i-2); cover=0; for(int j=0;j<len;j++)//高精度的思想 { temp=a[i][j]+cover; a[i][j]=temp%10; cover=temp/10; } while(cover)//最高位不为0 { a[i][len++]=cover%10; cover/=10; } cover=0; for(int j=len-1;j>=0;j--)//除法 { temp=cover*10+a[i][j]; a[i][j]=temp/(i+1); cover=temp%(i+1); } while(!a[i][len-1]) len--; b[i]=len; }}int main(){ // freopen("C:\\Users\\Administrator\\Desktop\\in.txt" , "r" , stdin); int n; Catanlan(); while(cin>>n) { for(int i=b[n]-1;i>=0;i--) { cout<<a[n][i]; } cout<<endl; } return 0;}
POJ2084
http://poj.org/problem?id=2084
import java.math.*;import java.io.*;import java.util.*;public class Main {public static void main(String[] args){Scanner cin =new Scanner(System.in);BigInteger num[] =new BigInteger[101];num[0]=BigInteger.ONE;num[1]=BigInteger.ONE;for(int i=2;i<101;i++){num[i]=num[i-1].multiply(BigInteger.valueOf(4*i-2)).divide(BigInteger.valueOf(i+1));}while(cin.hasNextInt()){int n=cin.nextInt();if(n==-1)break;System.out.println(num[n]);}}}
- 卡特兰数 大数
- 大数卡特兰数
- 大数卡特兰数
- 大数 卡特兰数
- 大数卡特兰数
- hdu1133 大数+卡特兰数
- 大数模板+卡特兰数
- 卡特兰数 大数模板
- 卡特兰数+大数处理
- 卡特兰数(catalan数)总结 (卡特兰大数、卡特兰大数取模、卡特兰数应用)
- hdu 1134 卡特兰数+大数
- [转]C++大数模板 卡特兰数
- HDU 1130(卡特兰数,大数)
- hdu 1023 大数 卡特兰数
- hdu 1023(大数+卡特兰数)
- 【卡特兰数+大数】HDU1131Count the Trees
- POJ 2084 大数+卡特兰数
- hdu 1134 卡特兰数(大数模板)
- 如何阅读文献(二)
- IOS 颜色渐变
- httpclient demo 3.1 4.2不同版本的API实现 解析JSON
- 矩阵快速幂
- 动态代理类的产生
- 大数卡特兰数
- Eclipse 常用快捷键
- According to TLD or attribute directive in tag file
- POJ3126 Prime Path
- Eclipse界面中文字体显示过小问题的解决办法
- sqlserver2008不能创建全文索引解决办法
- VI命令简录
- Android 手机截屏
- POJ 2406(KMP) 证明