Approach not getting

problem in making logic…

what if n<m?
You simply place all tiles horizontally!, so answer is 1.
now what if n=m?
You can either place all horizontally or all vertically, so answer is 2.
These are your base cases!
Now if n>m, you can place a tile horizontally(left with (n-1)Xm) or vertically(left with (n-m)Xm),
so answer is ways(n-1,m) + ways(n-m,m).
Now only recursion won’t work, so use DP (memoization)

sir, r u there ?..it’s still showing error

share your code for same!

#include #include<bits/stdc++.h> using namespace std; #define MOD 1000000007 #define ll long long ll tiling(int n,int m,int x,int y) { if(n==0) return 1; ll c1=0,c2=0; if(n<=y) { c1=tiling(n,m-1,x,y)%MOD; } c2=tiling(n-1,m,x,y)%MOD; ll c3=(c1+c2)%MOD; return c3; } int main() { int t; cin>>t;; while(t–) { int n,m; cin>>n>>m; ll int ans=0; ans=tiling(n,m,1,m); cout<<ans<<endl; } return 0; }

can u plzz tell what i have to do next ??

Your implementation is incorrect, see my code, it is same as what I already explained!

ok…thanks…now i can try