Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : sol_sub1
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 31 August 2021 [15:35]
- Algo :
- Status :
- */
- #include<bits/stdc++.h>
- #define rep(i, a, b) for(LL i = a; i <= (b); ++i)
- #define repr(i, a, b) for(LL i = a; i >= (b); --i)
- #define all(x) begin(x),end(x)
- #define allst(x,y) (x).begin()+y,(x).end()
- #define rmdup(x) sort(all(x)),(x).resize(unique((x).begin(),(x).end())-(x).begin())
- #define sz(x) (int)(x).size()
- #define decp(x) fixed << setprecision(x)
- #define MOD (LL )(1e9+7)
- using namespace std;
- using LL = long long;
- using PII = pair<int ,int >;
- using PLL = pair<long long ,long long >;
- const int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
- const int dir8[2][8] = {{-1,-1,-1,0,1,1,1,0},{-1,0,1,1,-1,0,1,-1}};
- LL modN(LL a,LL b,LL c = MOD){
- if(b == 0) return 1;
- if(b == 1) return a%c;
- LL now = modN(a,b/2,c);
- if(b&1) return (((now*now)%c)*(a%c))%c;
- else return (now*now)%c;
- }
- const int N = 810;
- LL f[N];
- void init(){
- f[1] = 1;
- rep(i,2,N-1)
- f[i] = i*f[i-1],f[i]%=MOD;
- }
- void solve(){
- int n,h;
- cin >> n >> h;
- cout << (((f[2*n] * modN(f[n+1],MOD-2))%MOD) * modN(f[n],MOD-2))%MOD << '\n';
- }
- int main(){
- cin.tie(0)->sync_with_stdio(0);
- cin.exceptions(cin.failbit);
- // freopen("d:/Code/C_Programming/input.in","r",stdin);
- init();
- int q = 1;
- cin >> q;
- for(int Q=1;Q<=q;Q++){
- // cout << "Case #" << Q << ": ";
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment