标签:ant close text bit using sed run lan nan
注意的是等于Cn+1
高精度卡特兰数
#include<bits/stdc++.h> #define BASE 10000 #define MAX 100010 using namespace std; struct BigInt{ int num[MAX],len; BigInt(int _ = 0) { num[len = 1] = _; } BigInt operator +(const BigInt &a)const { BigInt re; re.len = max(len,a.len); int temp = 0; for(int i = 1; i <= a.len; ++i) { re.num[i] = temp + num[i] + a.num[i]; temp = re.num[i] / BASE; re.num[i] %= BASE; } if(temp) re.num[++re.len] = temp; return re; } BigInt operator *(int a)const { BigInt re; re.len = len; int temp = 0; for(int i = 1; i <= len; ++i) { re.num[i] = temp + num[i] * a; temp = re.num[i] / BASE; re.num[i] %= BASE; } while(temp) re.num[++re.len] = temp % BASE,temp /= BASE; return re; } BigInt operator /(int a)const { BigInt re; re.len = len; int temp = 0; for(int i = len; i; --i) { re.num[i] = (temp + num[i]) / a; temp = (temp + num[i]) % a * BASE; } while(!re.num[re.len]) --re.len; return re; } }; int main() { //freopen("in.txt","r",stdin); int x; cin >> x; x=x+1; BigInt ans(1); for(int i = 2; i <= x; ++i) ans = ans * (4 * i - 2) / (i + 1); printf("%d",ans.num[ans.len]); for(int i = ans.len - 1; i; --i) printf("%04d",ans.num[i]); return 0; }
标签:ant close text bit using sed run lan nan
原文地址:https://www.cnblogs.com/kuroko-ghh/p/9556627.html