Meaning of the questions: A class of N individuals, B class M have personal, now make up a new class C class, to be fair, each drawn from the AB class the same number of people. Now find all the options, and the number of how many.
Idea: That is seeking Σ k * C (N, k ) * C (M, k); ignore the first outer layer k, a combination of two numbers to see how the product and demand.
Obviously Σ C (N, k) * C (M, k) = C (N + M, N); as C (N, k) = C (N, Nk); N can be selected as the number Nk, M k-selected, so that a number of combinations.
Now look at how to deal with this k. Noting k * C (N, k) = N * C (N-1, k-1); they can engage in the: Σ k * C (N, k) * C (M, k) = Σ N * C (N-1, k-1) * C (M, k) = C (N + M-1, N-1);
Lucas then do it.
#include<bits/stdc++.h> #define ll long long #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; const int Mod=19260817; const int maxn=19260817; int f[maxn],rev[maxn]; int qpow(int a,int x){ int res=1; while(x){ if(x&1) res=1LL*res*a%Mod; x>>=1; a=1LL*a*a%Mod; } return res; } void init() { f[0]=rev[0]=1; rep(i,1,maxn-1) f[i]=1LL*f[i-1]*i%Mod; rev[maxn-1]=qpow(f[maxn-1],Mod-2); for(int i=maxn-2;i>=1;i--) rev[i]=1LL*rev[i+1]*(i+1)%Mod; } int C(int N,int M) { if(N<M) return 0; return 1LL*f[N]*rev[M]%Mod*rev[N-M]%Mod; } int Lucas(ll N,ll M) { if(M==0) return 1; return 1LL*Lucas(N/Mod,M/Mod)*C(N%Mod,M%Mod)%Mod; } int main() { init(); int T; ll N,M; scanf("%d",&T); while(T--){ scanf("%lld%lld",&N,&M); printf("%d\n",2LL*M%Mod*Lucas(N+M-1,N-1)%Mod); } return 0; }