TLE Error in Tiling Problem

I am getting TLE error even after using the modulo
#include
using namespace std;
int f(long long int n,long long int m){
if(n<m && n>=0){
return 1;
}
if(n<0){
return 0;
}
int ans;
ans=f(n-1,m) + f(n-m,m);
return ans;

}
int main() {
int t;
cin>>t;
while(t–){
long long int n,m;
cin>>n>>m;
cout<< f(n,m)<<endl;
}
return 0;
}

hello @priyeshant1104
ur code is correct, but to pass all test cases u need to apply dynamic programming

Isn’t there any way to do it by recursion?

no there is not…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.