please tell me where my logic is going wrong
Test cases are not executing
#include
using namespace std;
#define mod 1000000007
int tiles(int n,int m,int *dp)
{
if(n<m)
{
return 1;
}
if(n==m)
return 2;
if(dp[n]!=0)
return dp[n];
dp[n]=(tiles(n-1,m,dp))%mod+(tiles(n-m,m,dp))%mod;
dp[n]=dp[n]%mod;
return dp[n];
}
int main() {
int n,m,t,l;
cin>>t;
while(t–)
{
int dp[100000]={0};
for(int i=0;i<50;i++)
cout<<dp[i];
cin>>n;
cin>>m;
cout<<tiles(n,m,dp);
}
return 0;
}
@rajeev071999
rajeev ur code was correct.just made simple modifications
a) changed datatype to long long
b) after printing output(answer) added \n
c) removed cout dp[i]
here is ur working code link - https://ide.codingblocks.com/s/183559
why should we go for long long rather than int