Why does my code gives TLE when i am supposed to apply recursion in it? If we are supposed to apply dp , then should’ve put it in dp section.
#include<bits/stdc++.h>
using namespace std;
int tiling(int n , int m){
if(n==m){
return 2;
}
if(n<=1 || n<m){
return 1;
}
return ((tiling(n-m , m)%1000000007)+(tiling(n-1 , m)%1000000007))%1000000007;
}
int main(){
int t;
cin>>t;
while(t–){
int n,m;
cin>>n>>m;
cout<<tiling(n,m)<<endl;
}
return 0;
}