用long long超时,五边形定理,虽然学了一点,但是还是不会啊
#include <cstdio>
#define LL long long
#define N 1000000007
int num[100010];
void solve()
{
num[0]=num[1]=1,num[2]=2;
for(int i=3; i<=100000; ++i)
for(int j=1,f=1;; ++j,f*=-1)
{
int a=(j*j*3-j)/2,b=(3*j*j+j)/2;
if(i<a) break;
num[i]=(num[i-a]*f+num[i])%N;
num[i]=(num[i]+N)%N;
if(i<b) break;
num[i]=(num[i-b]*f+num[i])%N;
num[i]=(num[i]+N)%N;
}
}
int main()
{
//freopen("in.txt","r",stdin);
solve();
int t,n,k;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
int ans=num[n];
for(int i=1,f=-1;; ++i,f*=-1)
{
int a=k*(i*i*3-i)/2,b=k*(i*i*3+i)/2;
if(a>n) break;
ans=(ans+num[n-a]*f)%N;
ans=(ans+N)%N;
if(b>n) break;
ans=(ans+num[n-b]*f)%N;
ans=(ans+N)%N;
}
printf("%d\n",ans);
}
return 0;
}