why this not work can you find the fault plz.
#include<iostream>
#include<cstring>
#define mod 1000000007
using namespace std;
long tileing(long *dp, long n, long &m){
if(dp[n]!=-1)
return dp[n];
long ans = tileing(dp, n-1, m)%mod;
long ans2 = tileing(dp, n-m, m)%mod;
dp[n] = (ans + ans2)%mod;
return dp[n];
}
int main() {
long t,m,n;
cin>>t;
while(t--){
cin>>n>>m;
// n=20;
// m=4;
if(n<m){
cout<<"1\n";
continue;
}
if(n==m){
cout<<"2\n";
continue;
}
long dp[n];
memset(dp,-1,sizeof(dp));
dp[0] = 0;
for(int i=1;i<m;i++)
dp[i]=1;
dp[m]=2;
cout << tileing(dp, n, m)<<endl;
// for(int i=0;i<10;i++)
// cout<<dp[i]<<" ";
}
return 0;
}