my solution is not working for large input of n and m
code:
#include
using namespace std;
typedef long long ll;
ll N=1000000007;
ll tilling(ll n,ll m){
if (m>n && n>=1) return 1;
else if (n<=0) return 0;
else if (m==n) return 2;
else return (tilling(n-1,m)%N+tilling(n-m,m)%n);
}
int main() {
ll t;
cin>>t;
while (t–){
ll n,m;
cin>>n>>m;
cout<<tilling(n,m)%(N)<<endl;
}
return 0;
}