提交时间:2022-08-08 11:31:08

运行 ID: 54925

#include<bits/stdc++.h> using namespace std; #define ll long long 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; } ll mod=998244353,ans; int n,m,t; inline ll A(int a) { ll sum=1; for(int i=2; i<=a; i++) sum=sum*i%mod; return sum%mod; } inline ll C(int n,int m) { ll sum=1; for(int i=m; i>m-n; i--) sum=sum*i%mod; return sum%mod; } int main() { t=read(); while(t--) { m=read(),n=read(); if(m>n+1) printf("0\n"); else { ans=A(n)*C(m,n+1)%mod; printf("%lld\n",ans); } } return 0; }