Guest User

Untitled

a guest
Nov 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  5.  
  6. int main() {
  7.  
  8.     fastio;
  9.  
  10.     ll test;
  11.     cin>>test;
  12.  
  13.     for(ll t=1; t<=test;t++)
  14.     {
  15.         vector<vector<ll>> a (40,vector<ll>(40));
  16.       ll x,y,c,b;
  17.       cin >> x >> y >> c >> b;
  18.  
  19.       for(ll i = 0 ; i <= x; i++) a[i][0] = 1;
  20.  
  21.  
  22.       for(ll i = 0 ; i <= y ; i++) a[0][i] = 1;
  23.  
  24.       a[c][b] = 0;
  25.  
  26.       for(ll i = 1; i < x+1 ; i++) {
  27.           for(ll j=1;j<y+1;j++) {
  28.               if(i == c && j == b) continue;
  29.               else{
  30.                   a[i][j]=a[i-1][j]+a[i][j-1];
  31.               }
  32.           }
  33.       }
  34.  
  35.       cout<<a[x][y] << "\n";
  36.  
  37.  
  38.     }
  39.  
  40.     return 0;
  41. }
Add Comment
Please, Sign In to add comment