提交时间:2022-08-08 11:32:15

运行 ID: 54940

#include<bits/stdc++.h> using namespace std; typedef unsigned long long ll; const int mo=998244353; ll m,n,t; inline ll read() { static ll 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; } inline ll a(ll m,ll n) { ll ans1=1; for(ll i=m; i>=(m-n+1); i--) ans1*=i%mo; return ans1%mo; } int main() { // freopen("line.in","r",stdin); // freopen("line.out","w",stdout); t=read(); while(t--) { m=read(),n=read(); if(m>n+1||n==0) { cout<<0<<endl; continue; } cout<<(a(n,n)*(a(n+1,m))%mo)<<endl; } return 0; }