Submit Time:2022-08-08 12:08:09

运行 ID: 55010

#include<bits/stdc++.h> #define ll long long #define mod 998244353 #define N 10000000 using namespace std; inline int read(){ int x(0),f(1);char c(getchar()); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} return x*f; } void write(ll x){ if(x>9) write(x/10); putchar(x%10^48); } ll fpow(ll a,ll b){ if(!b) return 1; ll t(fpow(a,b>>1)); if(b&1) return t*t%mod*a%mod; return t*t%mod; } ll f[N+5],inv[N+5]; int t,n,m; int main(){ // freopen("line.in","r",stdin); // freopen("line.out","w",stdout); f[0]=1;for(int i(1);i<=N;++i) f[i]=f[i-1]*i%mod; inv[N]=fpow(f[N],mod-2);for(int i(N-1);i>=0;--i) inv[i]=inv[i+1]*(i+1)%mod; t=read(); while(t--){ m=read();n=read(); if(n+1<m) puts("0"); else write(f[n]*f[n+1]%mod*inv[n+1-m]%mod),puts(""); } return 0; }