4 out of 5 test cases not passed due to tle

code:
#include
using namespace std;
int ways(int n,int m){
//base case
if(n<=m-1){
return 1;
}
//recursive
return ways(n-1,m)+ways(n-m,m);
}
int main(){
int t;
cin>>t;
int n,m;
for(int i=0;i<t;i++){
cin>>n>>m;
cout<<ways(n,m)<<endl;
}
cout<<endl;
}

hi @anshita_1312 updated https://ide.codingblocks.com/s/667729
use DP and do MOD

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.