标签:
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2082
然后包含N行数据,每行包含26个<=20的整数x1,x2,.....x26.
2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 2 6 2 10 2 2 5 6 1 0 2 7 0 2 2 7 5 10 6 10 2 10 6 1 9
7 379297
思路:(1)母函数
(2)题目实际上所要求的是x的指数小于等于50的全部系数和。
附上代码:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <cmath>
using namespace std;
int a[60],b[60]; //a[i]表示x^i的系数,
int main()
{
int t,num;
cin>>t;
while(t--)
{
for(int i=0;i<60;i++)//初始化
{
a[i]=0;
b[i]=0;
}
a[0]=1;//最初始为1
for(int i=1;i<=26;i++)
{
cin>>num;
if(num==0)continue;
for(int j=0;j<=50;j++)
for(int k=0;k<=num&&k*i+j<=50;k++)
{
b[k*i+j]+=a[j];
}
for(int j=0;j<=50;j++)
{
a[j]=b[j];
b[j]=0;
}
}
int total=0;
for(int i=1;i<=50;i++)
total+=a[i];
cout<<total<<endl;
}
return 0;
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
标签:
原文地址:http://www.cnblogs.com/lcchuguo/p/4650288.html