Advertisement
Saleh127

UVA 10910 / Combinatorics

Mar 15th, 2022
1,724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. /***
  2.  created: 2022-03-15-22.19.28
  3. ***/
  4.  
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7. #define ll long long
  8. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  9. #define get_lost_idiot return 0
  10. #define nl '\n'
  11. #define mod 1000000
  12.  
  13. ll f[1000];
  14. ll c[310][310];
  15. void fact()
  16. {
  17.     f[0]=1;
  18.     f[1]=1;
  19.  
  20.     for(ll i=2; i<=305; i++)
  21.     {
  22.         f[i]=(f[i-1]*i)%mod;
  23.     }
  24. }
  25.  
  26. ll bigmod(ll a,ll c,ll m)
  27. {
  28.  
  29.     if(c==0) return 1;
  30.     ll x=bigmod(a,c/2,m);
  31.     x=(x*x)%m;
  32.     if(c%2==1)
  33.     {
  34.         x=(x*a)%m;
  35.     }
  36.     return x;
  37. }
  38.  
  39. void nCr()
  40. {
  41.  
  42.     ll i,j,k,l;
  43.  
  44.     for(i=0; i<=302; i++)
  45.     {
  46.         c[i][0]=1;
  47.         for(j=1; j<=i; j++)
  48.         {
  49.             c[i][j]=(c[i][j]+c[i-1][j]+c[i-1][j-1]);
  50.         }
  51.     }
  52.  
  53.  
  54.  
  55.     /*
  56.  
  57.     if(r==1) return n;
  58.  
  59.     if(r==n) return 1;
  60.  
  61.     if(r>n) return 0;
  62.  
  63.  
  64.     ll j= bigmod(f[n-r],mod-2,mod);
  65.     ll k= bigmod(f[r],mod-2,mod);
  66.  
  67.     return (f[n]%mod*j%mod*k%mod)%mod;
  68.  
  69.     */
  70. }
  71.  
  72. int main()
  73. {
  74.     ios_base::sync_with_stdio(0);
  75.     cin.tie(0);
  76.     cout.tie(0);
  77.  
  78.     //fact();
  79.  
  80.     nCr();
  81.  
  82.     test
  83.     {
  84.         ll n,m,i,r,p,j,k,l;
  85.  
  86.         cin>>n>>m>>p;
  87.  
  88.         m-=(p*n);
  89.  
  90.         cout<<c[m+n-1][m]<<nl;
  91.  
  92.     }
  93.  
  94.  
  95.     get_lost_idiot;
  96. }
  97.  
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement