标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5733 Accepted Submission(s):
4033
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #define M 50 5 using namespace std; 6 int main() 7 { 8 int n,a[30],i,j,s,k; 9 int c1[M+5],c2[M+5]; 10 scanf("%d",&n); 11 while(n--) 12 { 13 for(i=1; i<=26; i++) 14 scanf("%d",&a[i]); 15 memset(c1,0,sizeof(c1)); 16 memset(c2,0,sizeof(c2)); 17 c1[0]=1; 18 for(i=1; i<=26; i++) 19 { 20 for(j=0; j<=M; j++) 21 for(k=0; k<=a[i]; k++) 22 { 23 if(j+k*i<=M) 24 c2[j+k*i]+=c1[j]; 25 else 26 break; 27 } 28 for(j=0; j<=M; j++) 29 { 30 c1[j]=c2[j]; 31 c2[j]=0; 32 } 33 } 34 int ans=0; 35 for(i=1; i<=M; i++) 36 ans+=c1[i]; 37 printf("%d\n",ans); 38 } 39 return 0; 40 }
标签:
原文地址:http://www.cnblogs.com/pshw/p/5346479.html