The main topic: high-precision Cattleya number.
Idea: Oberwieki Look, there is a model and the same problem, and then left the water of high precision.
(who will teach me Java ...)
CODE:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define BASE 10000 #define MAX 100010using 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 () {int x; CIN >> X; 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;}
Bzoj 2822 AHOI 2012 Tree House steps Cattleya + High precision