提交时间:2022-08-08 11:36:21
运行 ID: 54965
#include<bits/stdc++.h> using namespace std; #define LL long long const int Mod=998244353; inline LL read() { LL x=0; char c=getchar(); for(; c<'0' || c>'9'; c=getchar()); for(; c<='9' && c>='0'; c=getchar()) x=(x<<3)+(x<<1)+c-'0'; return x; } int main() { int t; cin>>t; while(t--) { LL ans=1,ans1=1,p=1,sum=1; LL n,m; m=read(),n=read(); for(int i=1;i<=m;i++) ans*=i,ans%=Mod; for(int i=1;i<=n;i++) sum*=i,sum%=Mod; for(int i=1;i<=n+1;i++) ans1*=i,ans1%=Mod; for(int i=1;i<=abs(n+1-m);i++) p*=i,p%=Mod; cout<<(ans%Mod*sum%Mod*(ans1/(ans*p%Mod)))%Mod<<endl; } }