提交时间:2022-08-08 11:33:20
运行 ID: 54948
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll Mod=998244353; ll n,m; int T; inline int read() { static int 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; } int main() { T=read(); while(T--) { m=read(),n=read(); if(m>n+1) printf("0\n"); else if(m==0) { ll sum1=1; for(int i=1; i<=n; i++) sum1*=(i%Mod); printf("%lld",sum1); } else { ll sum1=1; for(int i=1; i<=n; i++) sum1*=(i%Mod); ll sum2=1; for(int i=n+1; i>n+1-m; i--) sum2*=(i%Mod); ll sum=sum1*sum2; sum%=Mod; printf("%lld\n",sum); } } return 0; }