i am getting tle for 4 test cases , can u tell me the optimizations , here is my code:-
#include
using namespace std;
#define M 1000000007
int ways(int m,int n){
if(n<=3)
return 1;
else if(n==4)
return 2;
return ways(m,n-1)+ways(m,n-4);
}
int main() {
int t,m,n;
cin>>t;
while(t–){
cin>>n;
cin>>m;
cout<<ways(m,n)%M<<endl;
}
return 0;
}