90pts求调
查看原帖
90pts求调
852700
_jiuye_楼主2024/12/4 09:28
#include<bits/stdc++.h>
using namespace std;
int c[201],f[16][201];
void gjcheng(int a,int b){
    memset(c,false,sizeof(c));
    c[0]=f[a][0]+f[b][0];
    for(int i=1;i<=f[a][0];i++)
        for(int j=1;j<=f[b][0];j++){
            c[i+j-1]+=f[a][i]*f[b][j];
            c[i+j]+=c[i+j-1]/10;
            c[i+j-1]%=10;
        }
    if(c[c[0]+1]>0) c[0]++;
    while((c[c[0]]==0&&c[0]!=1)||c[0]>200){
    	c[c[0]]=0;
    	c[0]--;
	}
}
void gjjia(int k){
    f[k][1]++;
    for(int i=1;i<f[k][0];i++){
        f[k][i+1]+=f[k][i]/10;
        f[k][i]%=10;
    }
    if(f[k][f[k][0]+1]>0) f[k][0]++;
    while((f[k][f[k][0]]==0&&f[k][0]!=1)||f[k][0]>200){
    	f[k][f[k][0]]=0;
    	f[k][0]--;
	}
}
void gjjian(int a,int b){
    memset(c,false,sizeof(c));
    c[0]=f[a][0];
    for(int i=1;i<=c[0];i++){
        c[i]+=f[a][i]-f[b][i];
        if(c[i]<0) c[i+1]--;
        c[i]=(c[i]+10)%10;
    }
}
int main(){
//	freopen("narytree.in","r",stdin);
//	freopen("narytree.out","w",stdout);
	int n,d;
	cin>>n>>d;
	if(d==0){
		cout<<1;
		return 0;
	}
	f[0][0]=f[0][1]=1;
	for(int i=1;i<=d;i++){
		f[i][0]=f[i][1]=1;
		for(int j=1;j<=n;j++){
			gjcheng(i,i-1);
			swap(c,f[i]);
		}
		gjjia(i);
	}
	gjjian(d,d-1);
	if(c[0]>200){
		c[0]=200;
	}
	while(c[c[0]]==0&&c[0]>1) c[0]--;
    printf("%d",c[c[0]]);
    for(int i=c[0]-1;i>0;i--)
        printf("%d",c[i]);
	return 0;
}
2024/12/4 09:28
加载中...