HDU 1023 高精度 卡特兰数
2014-02-17 00:34
387 查看
题目:
Train Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5139 Accepted Submission(s): 2771
Problem Description
As we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many orders that all the trains can get out of the railway.
Input
The input contains several test cases. Each test cases consists of a number N(1<=N<=100). The input is terminated by the end of file.
Output
For each test case, you should output how many ways that all the trains can get out of the railway.
Sample Input
1
2
3
10
Sample Output
1
2
5
16796
Hint
The result will be very large, so you may not process it by 32-bit integers.
//h(n)=h(n-1)*(4*n-2)/(n+1) n=i+1卡特兰数的公式
//h(n)=h(n-1)*(4*n-2)/(n+1) n=i+1 #include<stdio.h> void main() { int a[100][101]={0},b[100]; int len=1,i,j,temp,n; a[0][0]=1; b[0]=1; temp=0; for(i=1;i<100;i++) { for(j=0;j<len;j++) { a[i][j]=a[i-1][j]*(4*i+2); a[i][j]+=temp; temp=a[i][j]/10; a[i][j]%=10; } while(temp) { a[i][len++]=temp%10; temp/=10; } temp=0; for(j=len- 4000 1;j>=0;j--) { a[i][j]+=temp*10; temp=a[i][j]%(i+2); a[i][j]/=i+2; } j=len-1; while(!a[i][j--]) len--; b[i]=len; } while(scanf("%d",&n)!=EOF) { for(i=b[n-1]-1;i>=0;i--) printf("%d",a[n-1][i]); printf("\n"); } }
相关文章推荐
- 【HDU-1023】 Train Problem II 【卡特兰数+高精度】
- hdu 1023 ——Train Problem II(卡特兰数+高精度+java)
- HDU 1023 Traning Problem (2) 高精度卡特兰数
- hdu 1023 卡特兰数+高精度
- HDU-1023 Train Problem II 卡特兰数(结合高精度乘除)
- HDU 1023 Train Problem II 卡特兰数 高精度
- 卡特兰数 Catalan数 hdu 1023
- HDU_1023_Train Problem II_卡特兰数
- Train Problem II HDU 1023 卡特兰数
- HDU 1023 Train Problem II (卡特兰数)
- HDU1023 Train Problem (卡特兰数)
- hdu 1023 Train Problem II(卡特兰数的应用)出栈序列的统计
- hdu 1023(大数+卡特兰数)
- HDU 1023 Train Problem II (卡特兰数)未解决未解决未解决未解决
- HDU 1023 (卡特兰数)
- hdu 1023+1030+1134 卡特兰数+大数模板处理
- 卡特兰数(HDU 1023)
- HDU 1023 卡特兰数
- hdu 1023 Train Problem II 完整高精度模板(以输出大Catalan为例)
- hdu 1023 大数 卡特兰数