BZOJ2822 AHOI2012 樹屋階梯

2021-07-12 01:49:43 字數 2124 閱讀 1774

設f[i]表示i個階梯的方案數,考慮你第乙個踩上去的階梯,他的高度一定為1,可以取1~i的長度,若其長度為j,搭在這一塊上邊的部分的方案數為f[j-1],不在上邊部分的方案與f[i-j]一一對應(砍掉最底下一行),於是就是卡特蘭數,質因數分解之後高精即可

#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;

#define maxn 10010

#define maxm 10010

#define inf 1000000000

#define mod 1000000007

#define ll long long

#define eps 1e-8

#define maxl 1010

char bnin[maxl];

struct bn

bn(int x)}

friend istream &operator >>(istream &input,bn &x)return input;}

friend ostream &operator <<(ostream &output,bn x)for(i=x.n;i;i--)this->n--;return *this;}

friend bool operator <(bn x,bn y)

friend bool operator <(bn x,ll y)

friend bool operator <=(bn x,ll y)

friend bool operator >=(bn x,ll y)

friend bool operator <(ll x,bn y)

friend bool operator <=(ll x,bn y)

friend bool operator >=(ll x,bn y)

friend bn operator +(bn x,bn y)z.n=max(x.n,y.n);if(z.x[z.n+1])return z;}

friend bn operator -(bn x,bn y)}z.n=max(x.n,y.n);while(!z.x[z.n]&&z.n)return z;}

friend bn operator *(bn x,bn y)}z.n=x.n+y.n;while(!z.x[z.n]&&z.n)return z;}

friend bn operator +(bn x,ll y)

friend bn operator -(bn x,ll y)

friend bn operator *(bn x,ll y)

friend bn operator +(ll x,bn y)

friend bn operator -(ll x,bn y)

friend bn operator *(ll x,bn y)

friend bn operator /(bn x,bn y)else}return z;}

friend bn operator /(bn x,ll y)

friend bn operator /(ll x,bn y)

friend bn operator %(bn x,bn y)

bn operator +=(bn x)

bn operator -=(bn x)

bn operator *=(bn x)

bn operator /=(bn x)

bn operator %=(bn x)

bn operator +=(ll x)

bn operator -=(ll x)

bn operator *=(ll x)

bn operator /=(ll x)

bn operator %=(ll x)

ll tonum()return re;}

friend bn sqrt(bn x)else}return z;}

};int n;

int p[maxn],tot;

bool np[maxn];

int cnt[maxn];

void su(){

int i,j;

for(i=2;i

AHOI2012 BZOJ2822 樹屋階梯

description 暑假期間,小龍報名了乙個模擬野外生存作戰訓練班來鍛鍊體魄,訓練的第乙個晚上,教官就給他們出了個難題。由於地上露營濕氣重,必須選擇在高處的樹屋露營。小龍分配的樹屋建立在一顆高度為n 1尺 n為正整數 的大樹上,正當他發愁怎麼爬上去的時候,發現旁邊堆滿了一些空心四方鋼材 如圖1....

BZOJ2822 AHOI2012 樹屋階梯

標籤 數學,卡特蘭數,高精度 description 暑假期間,小龍報名了乙個模擬野外生存作戰訓練班來鍛鍊體魄,訓練的第乙個晚上,教官就給他們出了個難題。由於地上露營濕氣重,必須選擇在高處的樹屋露營。小龍分配的樹屋建立在一顆高度為n 1尺 n為正整數 的大樹上,正當他發愁怎麼爬上去的時候,發現旁邊堆...

2822 AHOI2012 樹屋階梯

time limit 1 sec memory limit 128 mb submit 729 solved 424 submit status discuss 暑假期間,小龍報名了乙個模擬野外生存作戰訓練班來鍛鍊體魄,訓練的第 乙個晚上,教官就給他們出了個難題。由於地上露營濕氣重,必須選擇在高處的...