1:一个讲解的很详细的五边型数的博客http://blog.csdn.net/zhoufenqin/article/details/9821617;
2:题目;hdu4651,最简单的五边形数,母函数应该也可以做(N^3),,五边形数是(N^1.5);
HDU4658,5230;变形版;
HDU5230的代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
typedef __int64 LL;
const int Maxn=100010;
const LL MOD=998244353;
LL Q[Maxn],P[Maxn];
LL GetQ(LL x)
{
LL ans=(LL)x*x*3-x;
return (ans/2)%MOD;
}
void _init()
{
Q[0]=0;
for(int i=1;i<Maxn;i++)
{
if(i&1) Q[i]=GetQ(i/2+1);
else Q[i]=GetQ(i/2*(-1));
}
P[0]=P[1]=1;
for(int i=2;i<Maxn;i++)
{
for(int j=1;;j++)
{
if(Q[j]>i) break;
int t=j;
if(t&1) t=t/2+1;
else t=t/2;
if(t&1)
P[i]=(P[i]+P[i-Q[j]]);
else
P[i]=(P[i]-P[i-Q[j]]);
if(P[i]>=MOD) P[i]%=MOD;
if(P[i]<0) P[i]+=MOD;
}
}
}
LL solved(LL n)
{
LL ans=0;
for(int i=0;;i++)
{
if(Q[i]*2>n) break;
//cout<<i<<" "<<Q[i]<<endl;
int t=i;
if(t&1) t=t/2+1;
else t=t/2;
if(t&1) ans=(ans-P[n-Q[i]*2]);
else ans=(ans+P[n-Q[i]*2]);
if(ans>=MOD) ans%=MOD;
if(ans<0) ans+=MOD;
//cout<<ans<<endl;
}
//printf("%I64d\n",ans);
return ans;
}
int main()
{
_init();
int T;
scanf("%d",&T);
while(T--)
{
LL C,L,D,n;
scanf("%I64d%I64d%I64d%I64d",&n,&C,&L,&D);
int i;
LL ans=0;
for(i=L-C;i<=D-C;i++)
{
ans+=solved(i);
ans=(ans+MOD)%MOD;
//cout<<ans<<endl;
}
printf("%I64d\n",ans);
}
return 0;
}