/*
五边形数定理,给以下链接,不再累述
http://zh.wikipedia.org/wiki/%E4%BA%94%E9%82%8A%E5%BD%A2%E6%95%B8%E5%AE%9A%E7%90%86
*/
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define P 1000000007
#define N 100010
int a[N];
int main()
{
a[0]=1;
for(int n=1;n<N;n++)
{
int S=0;
for(int i=1,w=0;;i++)
{
w+=2*i-1;
if(w>n)break;
if(i&1)S=(S+a[n-w])%P;
else S=(S-a[n-w]+P)%P;
w+=i;
if(w>n)break;
if(i&1)S=(S+a[n-w])%P;
else S=(S-a[n-w]+P)%P;
}
a[n]=S;
}
int T;
scanf("%d",&T);
while(T--){
int tt;
scanf("%d",&tt);
printf("%d\n",a[tt]);
}
return 0;
}
hdu 4651 Partition 五边形数定理
最新推荐文章于 2021-07-19 11:50:37 发布