hdu2082 找单词 母函数

给出不同字母的权值,计算有多少种字母组合权值小于50,母函数裸题

 1 #include<stdio.h>
 2 #include<string.h>
 3 
 4 long long c1[51],c2[51];
 5 
 6 int main(){
 7     int N;
 8     while(scanf("%d",&N)!=EOF){
 9         for(int q=1;q<=N;q++){
10             int i,j;
11             memset(c1,0,sizeof(c1));
12             c1[0]=1;
13             for(i=1;i<=26;i++){
14                 memset(c2,0,sizeof(c2));
15                 int b;
16                 scanf("%d",&b);
17                 for(int p=1;p<=b;p++){
18                     for(j=0;j+p*i<=50;j++){
19                         c2[j+p*i]+=c1[j];
20                     }
21                 }
22                 for(j=1;j<=50;j++)c1[j]+=c2[j];
23             }
24             long long ans=0;
25             for(i=1;i<=50;i++) ans+=c1[i];
26             printf("%d
",ans);
27         }
28     }
29     return 0;
30 }
View Code
原文地址:https://www.cnblogs.com/cenariusxz/p/6578126.html