Description
The number of schemes to be spelled in a ladder-like form.
Sol
High precision +catalan number.
We can extend the last line wirelessly, and it's easy to see the number of Catalan.
\ (f_n=f_0f_{n-1}+f_1f_{n-2}+f_2f_{n-3}+...+f_{n-1}f_0\)
This is the number of Catalan, high-precision sticker board ...
Code
/************************************************************** problem:2822 User:beiyu language:c++ Result : Accepted time:20 ms memory:1308 kb****************************************************************/#include <cs tdio> #include <cmath> #include <vector> #include <algorithm> #include <iostream>using namespace Std; typedef long LONG ll;const int B = 10;const int W = 1; struct big{vector<int> s; void Clear () {s.clear ();} Big (LL num=0) {*this=num;} Big operator = (LL x) {clear (); do{S.push_back (x%b), x/=b;} while (x); return *this; } Big operator = (const string &str) {clear (); int x,len= (Str.length ()-1)/w+1,l=str.length (); for (int i=0;i<len;i++) {int Tt=l-i*w,st=max (0,TT-W); SSCANF (Str.substr (st,tt-st). C_STR (), "%d", &x); S.push_back (x); }return *this; }}; istream& operator >> (IStream & In,big&a) {string S; if (! ( In>>s)) return in; A=s;return in;} ostream& operator << (ostream &out,const Big &a) {cout<<a.s.back (); for (int i=a.s.size () -2;~i;i--) {cout.width (W), Cout.fill (' 0 '),cout<<a.s[i]; }return out;} BOOL operator < (const big &a,const big &b) {int la=a.s.size (), lb=b.s.size (); if (LA<LB) return 1;if (LA>LB) return 0; for (int i=la-1;~i;i--) {if (A.s[i]<b.s[i]) return 1; if (A.s[i]>b.s[i]) return 0; }return 0;} BOOL operator <= (const big &a,const big &b) {return! B<A); }bool operator > (const big &a,const big &b) {return b<a;} BOOL operator >= (const big &a,const big &b) {return! A<B); }bool operator = = (Const Big &a,const big &b) {return! A>B) &&! (A<B); }bool operator! = (const Big &a,const big &b) {return a>b | | a<b;} Big operator + (const big &a,const big &b) {BiG C;c.clear (); int Lim=max (A.s.size (), B.s.size ()), La=a.s.size (), Lb=b.s.size (), i,g,x; for (i=0,g=0;; i++) {if (g==0 && i>=lim) break; X=g;if (I<la) x+=a.s[i];if (i<lb) x+=b.s[i]; C.s.push_back (x%b), g=x/b; }i=c.s.size ()-1; while (c.s[i]==0 && i) c.s.pop_back (), i--; return c;} Big operator-(const big &a,const big &b) {big c;c.clear (); int i,g,x,la=a.s.size (), lb=b.s.size (); for (i=0,g=0;i<la;i++) {x=a.s[i]-g; if (i<lb) x-=b.s[i]; if (x>=0) G=0;else g=1,x+=b; C.s.push_back (x); }i=c.s.size ()-1; while (c.s[i]==0 && i) c.s.pop_back (), i--; return c;} Big operator * (const big &a,const big &b) {Big C; int i,j,la=a.s.size (), Lb=b.s.size (), lc=la+lb; C.s.resize (lc,0); for (i=0;i<la;i++) for (j=0;j<lb;j++) c.s[i+j]+=a.s[i]*b.s[j]; for (i=0;i<lc;i++) c.s[i+1]+=c.s[i]/b,c.s[i]%=b; I=lc-1;while (c.s[i]==0 && i) c.s.pop_back (), i--; return c;} BIG operator/(const big &a,const big &b) {big c,f=0; int la=a.s.size (), I; C.s.resize (la,0); for (i=la-1;~i;i--) {f=f*b,f.s[0]=a.s[i]; while (f>=b) f=f-b,c.s[i]++; }i=la-1;while (c.s[i]==0 && i) c.s.pop_back (), i--; return c;} Big operator% (const big &a,const big &b) {Big c=a-(A/b) *b; return c;} Big operator ^ (Big &a,big &b) {big c=1; for (; b!=0;b=b/2,a=a*a) {if (B.s[0] & 1) c=c*a; }return C;} Big operator + = (Big &a,const big &b) {return a=a+b;} Big operator-= (big &a,const big &b) {return a=a-b;} Big operator *= (Big &a,const big &b) {return a=a*b;} Big operator/= (Big &a,const big &b) {return a=a/b;} Big operator%= (Big &a,const big &b) {return a=a%b;} const int N = 1005; int Cnt;int B[n],pr[n],minp[n],c[n]; void Pre (int t) {minp[1]=0; for (int i=2;i<=t;i++) {if (!b[i]) pr[++cnt]=i,minp[i]=cnt; for (int j=1;j<=cnt &&i*pr[j]<=t;j++) {b[i*pr[j]]=1,minp[i*pr[j]]=j; if (i%pr[j]==0) break; }}}void Add (int x,int v) {while (x>1) c[minp[x]]+=v,x/=pr[minp[x]];} int main () {Ios::sync_with_stdio (false); int n; Big ans=1,a,b; cin>>n; Pre (n*2); for (int i=n+1;i<=2*n;i++) ADD (i,1); for (int i=1;i<n;i++) ADD (i,-1); Add (n,-1), add (n+1,-1); for (int i=1;i<=cnt;i++) a=pr[i],b=c[i],ans*=a^b; cout<<ans<<endl; return 0;}
Bzoj 2822: [AHOI2012] Tree house ladder