提交时间:2022-08-08 11:39:57

运行 ID: 54974

#include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; const ll Mod=998244353; 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; } ll p(ll n) { ll ans=1; for(int i=1; i<=n; i++) ans=(ans*i)%Mod; return ans; } int main() { // freopen("line.in","r",stdin); // freopen("line.out","w",stdout); ll t=Read(); while(t--) { ll m=Read(),n=Read(); if(m>n+1) { printf("0\n"); continue; } ll ans=(p(n)*p(m))%Mod; ans=(ans*p(n+1)/p(n+1-m)/p(m))%Mod; printf("%lld\n",ans); } return 0; }