Advertisement
Saleh127

Spoj Marbels

Oct 5th, 2021
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  5.  
  6. ll nCr(ll n,ll r)
  7. {
  8.      ll x,y,a;
  9.  
  10.      if(r>n-r) r=n-r;
  11.  
  12.      x=1;
  13.  
  14.      for(ll i=0;i<r;i++)
  15.      {
  16.           x=x*(n-i)/(i+1);
  17.      }
  18.  
  19.      return x;
  20. }
  21.  
  22. int main()
  23. {
  24.    ios_base::sync_with_stdio(0);
  25.    cin.tie(0);cout.tie(0);
  26.  
  27.    test
  28.    {
  29.         ll n,m;
  30.  
  31.         cin>>n>>m;
  32.  
  33.         n--,m--;
  34.  
  35.         cout<<nCr(n,m)<<endl;
  36.    }
  37.  
  38.  
  39.    return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement