提交时间:2022-08-08 11:35:46

运行 ID: 54959

#include <bits/stdc++.h> using namespace std; #define ll long long inline void Read(ll &x) { char ch=getchar();x=0; while(!isdigit(ch)) ch=getchar(); while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); } const ll mod=998244353; ll T,m,n; int main() { // freopen("line.in","r",stdin); // freopen("line.out","w",stdout); Read(T); while(T--) { Read(m),Read(n); if(m==1) { ll ans=1; for(int i=n+1; i>=1; i--) ans=ans*i%mod; printf("%lld\n",ans); } else { ll ans=1; for(int i=n; i>=1; i--) ans=ans*i%mod; for(int i=n+1,j=1; j<=m; i--,j++) ans=ans*i%mod; printf("%lld\n",ans); //ans=A_n^n \times A_{n+1}^m //TLE 109s } } return 0; }