Tilling Problem - Time Limit

#include
#define ll long long
using namespace std;

ll calculator(ll n, ll m)
{
//base case

if(n < m || n==1){
	return 1;
}

else{
	return calculator(n-1, m) + calculator(n-m, m);
}

}

int main() {

int t;
cin>>t;

while(t--)
{
	ll n,m;
	cin>>n>>m;

	cout<<calculator(n,m)<<endl;
}


return 0;

}

@abhishekchoudhary You have not memoised your solution. Try to memoizing it by storing the n and m and they simple return its answer if you have calculated them so that you can avoid redundant computation.