#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define gc getchar
#define ull unsigned long long
#define ll long long
#define R register
#define il inline
#define int ll
using namespace std;
il ll read(){
ll ans = 0;
int f = 1;
char ch = gc();
while(ch<'0'||ch>'9'){
if(ch=='-'){
f = -1;
}
ch = gc();
}
while(ch>='0'&&ch<='9'){
ans = ans*10 + ch - '0';
ch = gc();
}
return ans*f;
}
il ll quickpow(ll a,ll b,ll n){
if(b==0){
return 1;
}
ll ans = 1;
while(b){
if(b%2==1)ans = ans * a % n;
a = a * a % n;
b = b / 2;
}
return ans;
}
const int M = 19491001;
ll f[M+100],n,m;
int C(int a, int b,int p){
if(a<b){
return 1;
}
return f[a]*quickpow(f[a-b],p-2,p)%p*quickpow(f[b],p-2,p)%p;
}
int locas(int a,int b,int p){
if(a<b)return 0;
if(!a) return 1;
return locas(a/p,b/p,p)%p * C(a%p,b%p,p)%p;
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
int T = read();
f[0] = 1;
for(int i = 1; i <= M; i++){
f[i] = (f[i-1]*i)%M;
f[i] %= M;
}
while(T--){
n = read();
m = read();
cout<<locas(n+m,m,M)<<endl;
}
// fclose(stdin);
// fclose(stdout);
return 0;
}
评测记录:
https://www.luogu.com.cn/record/43107042