提交时间:2022-08-08 12:01:05
运行 ID: 55003
#include <iostream> #include <cstdio> #define ll long long using namespace std; const ll MOD = 998244353; const int N = 10000002; ll jc[N],inv[N]; inline ll read(){ static ll x = 0, c=getchar(); for(;c <=47|| c >=58; c=getchar( )) ; for( x=0; c>=48&&c <=57; c=getchar( )) x=(x<<3)+(x<<1)+(c &15); return x; } inline void Init() { jc[1] = 1; inv[0] = inv[1] = 1; for(int i(2);i < N;i++) jc[i] = jc[i - 1] * i % MOD; inv[N - 1] = 243880830; for(int i(N - 2);i >= 1;i--) inv[i] = inv[i + 1] * (i + 1) % MOD; } int main() { //freopen("line.in","r",stdin); //freopen("line.out","w",stdout); Init(); int T; T = read(); while(T--) { ll m,n,ans = 1; m = read(); n = read(); if(n + 1 >= m) ans = jc[n] * jc[n + 1] % MOD * inv[n - m + 1] % MOD; else ans = 0; printf("%lld\n",ans); } return 0; }