运用生成函数求对于有权值的多个堆,每个对应的权值有多少种组合方法。
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int T;
int inp[100];
long long c1[100],c2[100];
cin>>T;
while(T--)
{
for(int i=1;i<=26;i++)
cin>>inp[i];
memset(c1,0,sizeof(c1));
memset(c2,0,sizeof(c2));
for(int i=0;i<=inp[1];i++)
c1[i]=1;
for(int i=2;i<=26;i++)
{
for(int j=0;j<=inp[i];j++)
{
for(int k=0;k<=51;k++)
{
int c=k+i*j;
if(c>=51) c=51;
c2[c]+=c1[k];
}
}
for(int j=0;j<=50;j++)
c1[j]=c2[j];
memset(c2,0,sizeof(c2));
}
long long ans=0;
for(int i=0;i<=50;i++)
ans+=c1[i];
cout<<ans-1<<endl;
}
return 0;
}