标签:ace class void main += names include namespace max
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 const int maxn=507; 5 int c[maxn][maxn][maxn],ans[maxn]; 6 int k,w; 7 void add(int a[],int b[],int c[]){ 8 c[0]=max(a[0],b[0]); 9 for(int i=1;i<=c[0];i++){ 10 c[i]+=a[i]+b[i]; 11 c[i+1]+=c[i]/10; 12 c[i]%=10; 13 } 14 if(c[c[0]+1]>0) c[0]++; 15 } 16 void addd(int a[],int b[]){ 17 a[0]=max(a[0],b[0]); 18 for(int i=1;i<=a[0];i++){ 19 a[i]+=b[i]; 20 a[i+1]+=a[i]/10; 21 a[i]%=10; 22 } 23 if(a[a[0]+1]>0) a[0]++; 24 } 25 int main(){ 26 cin>>k>>w; 27 int ix=1<<k;int iy=1<<(w%k); 28 for(int i=0;i<=ix;i++){ 29 for(int j=0;j<=i;j++){ 30 if(j==0){ 31 c[i][j][0]=1;c[i][j][1]=1; 32 } 33 else add(c[i-1][j],c[i-1][j-1],c[i][j]); 34 } 35 } 36 for(int i=2;i<=w/k&&i<ix;i++) addd(ans,c[ix][i]); 37 for(int i=1;i<iy&&i<=ix-1;i++) addd(ans,c[ix-i-1][w/k]); 38 for(int i=ans[0];i>=1;i--){ 39 cout<<ans[i]; 40 }cout<<endl; 41 return 0; 42 }
标签:ace class void main += names include namespace max
原文地址:https://www.cnblogs.com/lcan/p/9692947.html