fork download
  1. #include<bits/stdc++.h>
  2. #define mod 1000000007
  3. using namespace std;
  4.  
  5. int tiling(int n, int m){
  6.  
  7. if(n==1)
  8. return 1;
  9.  
  10. if(n<=0)
  11. return 0;
  12.  
  13. if(n<m)
  14. return 1;
  15.  
  16. if(n==m)
  17. return 2;
  18.  
  19. long long int ans1 = tiling(n-1,m);
  20. long long int ans2 = tiling(n-m,m);
  21.  
  22. return (ans1 + ans2)%mod;
  23.  
  24. }
  25.  
  26.  
  27. int main(){
  28.  
  29. int t;
  30. cin>>t;
  31. while(t--){
  32.  
  33. int n,m;
  34. cin>>n>>m;
  35. cout<<tiling(n,m)<<endl;
  36. }
  37. }
  38.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty