/*
//hdu 1028
//(1+x+x^2+x^3...) * (1+x^2+x^4+x^6....) * (1+x^3+x^6+x^9.....)*(1+x^4+x^8+x^12.....)*......
#include <iostream>
#include <string.h>
using namespace std;
const int maxn=122;
int temp[maxn];
int c[maxn];
int n;
int main()
{
while(cin>>n)
{
for(int i=0;i<=n;i++)
{
temp[i]=0;
c[i]=1;
}//第一项
for(int i=2;i<=n;i++)//第几个式子
{
for(int j=0;j<=n;j++)//原来式子的指数
for(int k=0;k+j<=n;k+=i)//当前式子的指数
temp[k+j]+=c[j];//指数相乘,原来系数保留,因为当前式子所有的指数的系数都为1
for(int i=0;i<=n;i++)
{
c[i]=temp[i];
temp[i]=0;
}
}
cout<<c[n]<<endl;
}
return 0;
}
*/
/*
//hdu 1398
//母函数为 (1+x+x^2+x^3+x^4...) * (1+x^4+x^8+x^12+x^16...) *(1+x^9+x^18+x^27...) * ...*(1+x^289+x^(289*2)+...)
#include <iostream>
using namespace std;
const int maxn=310;
int c[maxn];
int temp[maxn];
int n;
int main()
{
while(cin>>n&&n)
{
for(int i=0;i<=n;i++)
{
c[i]=1;
temp[i]=0;
}
for(int i=2;i*i<=n;i++)
{
for(int j=0;j<=n;j++)
for(int k=0;k+j<=n;k+=i*i)
temp[k+j]+=c[j];
for(int j=0;j<=n;j++)
{
c[j]=temp[j];
temp[j]=0;
}
}
cout<<c[n]<<endl;
}
return 0;
}
*/
/*
//hdu 1085
//(1+x +x^2+x^3+..x^num1) *( 1+x^2+x^4+x^6+.....x^num2) *( 1+x^5+x^10+x^15+....x^num5),只有三项
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
const int maxn=8100;
int temp[maxn];
int c[maxn];
int num[6];
int main()
{
while(cin>>num[1]>>num[2]>>num[3]&&(num[1]||num[2]||num[3]))
{
int MAX=num[1]+2*num[2]+5*num[3];//最大指数
memset(c,0,sizeof(c));
for(int i=0;i<=num[1];i++)
c[i]=1;
for(int i=2;i<=3;i++)
{
memset(temp,0,sizeof(temp));
for(int j=0;j<=MAX;j++)
for(int k=0;k<=num[i];k++)
{
if(i==2)
temp[j+k*2]+=c[j];
else
temp[j+k*5]+=c[j];
}
for(int i=0;i<=MAX;i++)
c[i]=temp[i];
}
bool ok=1;
for(int i=0;i<=MAX;i++)
if(c[i]==0)
{
ok=0;
cout<<i<<endl;
break;
}
if(ok)
cout<<MAX+1<<endl;
}
return 0;
}
*/
[ACM] 几道母函数题目 hdu 1028 1398 1085
最新推荐文章于 2019-09-22 15:22:00 发布