I am getting TLE in all the test cases except one:
what is the error in the code, I couldn’t identify.
#include<bits/stdc++.h>
using namespace std;
long int tile(long int n,long int m)
{
if(n==0)
{
return 0;
}
if(n<m||n==1)
{
return 1;
}
if(n==m)
{
return 2;
}
return tile(n-1,m)+tile(n-m,m);
}
int main()
{
int t;
cin>>t;
while(t--)
{
long int n,m;
cin>>n>>m;
long int ans=tile(n,m);
cout<<ans<<"\n";
}
}