我是靠谱客的博主 机灵大地,这篇文章主要介绍卡特兰数+高精C++模板,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream> #include <stdio.h> using namespace std; int a[101][101]={0}; int main() { int n,i,j,len,r,temp,t; int b[101]; a[1][0] = 1; len = 1; b[1] = 1; for(i=2;i<=100;i++) { t = i-1; for(j=0;j<len;j++) //乘法 a[i][j] = a[i-1][j]*(4*t+2); for(r=j=0;j<len;j++) { //处理相乘结果 temp = a[i][j] + r; a[i][j] = temp % 10; r = temp / 10; } while(r) { //进位处理 a[i][len++] = r % 10; r /= 10; } for(j=len-1,r=0;j>=0;j--) { //除法 temp = r*10 + a[i][j]; a[i][j] = temp/(t+2); r = temp%(t+2); } while(!a[i][len-1]) //高位零处理 len --; b[i] = len; } cin>>n; for(j=b[n]-1;j>=0;j--) printf("%d",a[n][j]); return 0; }

最后

以上就是机灵大地最近收集整理的关于卡特兰数+高精C++模板的全部内容,更多相关卡特兰数+高精C++模板内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(111)

评论列表共有 0 条评论

立即
投稿
返回
顶部