I don’t know what is wrong with my code. I saw the hint and coded the same way, using exactly the same recurrence but still my code fails every test case.
Please help and point out the bug
#include
#include
using namespace std;
unsigned long long countWays(int n, int m)
{
// bottom
unsigned long long DP[n+1];
for(int i=0; i< m; i++)
DP[i] = 1;
for(int i=m; i<=n; i++)
DP[i] = DP[i-1] + DP[i-m];
unsigned long long mod;
mod = pow(10, 9) + 7;
return DP[n]%mod;
}
int main() {
int n, m;
int T;
cin>>T;
while(T–){
cin>>n>>m;
cout<<countWays(n,m);
}
return 0;
}