卡特兰数
来源:互联网 发布:中国审美欧化 知乎 编辑:程序博客网 时间:2024/04/28 21:35
#include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<cstdio>#include<string>#include<set>#include<map>#include<queue>#include<stack>using namespace std;#define LL long long#define N 1000000009#define cl(a,b) memset(a,b,sizeof(a))int a[105][105];//大数卡特兰数int b[105];//卡特兰数的长度void catalan()//求卡特兰数{ int i,j,len,carry,temp; a[1][0]=b[1]=1; len=1; for(i=2;i<=100;i++) { for(j=0;j<len;j++)//乘法 a[i][j]=a[i-1][j]*(4*(i-1)+2); carry=0; for(j=0;j<len;j++)//处理相乘结果 { temp=a[i][j]+carry; a[i][j]=temp%10; carry=temp/10; } while(carry)//进位处理 { a[i][len++]=carry%10; carry/=10; } carry=0; for(j=len-1;j>=0;j--)//除法 { temp=carry*10+a[i][j]; a[i][j]=temp/(i+1); carry=temp%(i+1); } while(!a[i][len-1])//高位零处理 len--; b[i]=len; }}int main(){ int i,n; catalan(); while(~scanf("%d",&n)) { for(i=b[n]-1;i>=0;i--) { printf("%d",a[n][i]); } printf("\n"); } return 0;}//hdu1023
//类似hdu1134
0 0
- 卡特兰数,高精度卡特兰数
- 卡特兰数
- 卡特兰数(Catalan)
- 卡特兰数
- 卡特兰数
- 卡特兰数 大数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- 卡特兰数
- QT 等待对话框/进度--
- 点击CheckBox复选框是否记住密码
- 一个国贸作业
- 调用系统的短信和邮件功能,实现发送指定内容等
- 使用Spring(九)自动装配(autowire)协作者
- 卡特兰数
- 在window下,如何把自己的项目代码上传到Github上?
- STL学习之路二(set与multiset)
- github版本回退
- Leetcode 419. Battleships in a Board 战舰数量 解题报告
- 什么是make config,make menuconfig,make oldconfig,make xconfig,make defconfig,make gconfig?
- 运用Struts2数据验证实现注册表单验证
- super-diamond服务器搭建及应用
- python刚入门的坑