MAGCARI

Plant Tree Sub1

Sep 18th, 2021
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. /*
  2.     Task    : sol_sub1
  3.     Author  : Phumipat C. [MAGCARI]
  4.     Language: C++
  5.     Created : 31 August 2021 [15:35]
  6.     Algo    :
  7.     Status  :
  8. */
  9. #include<bits/stdc++.h>
  10. #define rep(i, a, b) for(LL i = a; i <= (b); ++i)
  11. #define repr(i, a, b) for(LL i = a; i >= (b); --i)
  12. #define all(x) begin(x),end(x)
  13. #define allst(x,y) (x).begin()+y,(x).end()
  14. #define rmdup(x) sort(all(x)),(x).resize(unique((x).begin(),(x).end())-(x).begin())
  15. #define sz(x) (int)(x).size()
  16. #define decp(x) fixed << setprecision(x)
  17. #define MOD (LL )(1e9+7)
  18. using namespace std;
  19. using LL = long long;
  20. using PII = pair<int ,int >;
  21. using PLL = pair<long long ,long long >;
  22. const int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
  23. const int dir8[2][8] = {{-1,-1,-1,0,1,1,1,0},{-1,0,1,1,-1,0,1,-1}};
  24. LL modN(LL a,LL b,LL c = MOD){
  25.     if(b == 0)  return 1;
  26.     if(b == 1)  return a%c;
  27.     LL now = modN(a,b/2,c);
  28.     if(b&1) return (((now*now)%c)*(a%c))%c;
  29.     else    return (now*now)%c;
  30. }
  31. const int N = 810;
  32. LL f[N];
  33. void init(){
  34.     f[1] = 1;
  35.     rep(i,2,N-1)
  36.         f[i] = i*f[i-1],f[i]%=MOD;
  37. }
  38. void solve(){
  39.     int n,h;
  40.     cin >> n >> h;
  41.     cout << (((f[2*n] * modN(f[n+1],MOD-2))%MOD) * modN(f[n],MOD-2))%MOD << '\n';
  42. }
  43. int main(){
  44.     cin.tie(0)->sync_with_stdio(0);
  45.     cin.exceptions(cin.failbit);
  46.     // freopen("d:/Code/C_Programming/input.in","r",stdin);
  47.     init();
  48.     int q = 1;
  49.     cin >> q;
  50.     for(int Q=1;Q<=q;Q++){
  51.         // cout << "Case #" << Q << ": ";
  52.         solve();
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment