提交时间:2022-08-08 11:43:37
运行 ID: 54983
#include <bits/stdc++.h> using namespace std; #define N 10000005 #define mod 998244353 #define ll long long 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 fp[N + 5], ifp[N + 5]; ll fpow(ll x, ll y) { ll ans = 1; while (y) { if (y & 1) (ans *= x) %= mod; y >>= 1; (x *= x) %= mod; } return ans; } void write(ll x) { if (x > 9) write(x / 10); putchar(x % 10 ^ 48); } ll t, a, b; int main() { // scanf("%lld", &t); t = read(); fp[0] = 1;ifp[0] = 1; for (int i(1); i <= N; ++i) { fp[i] = fp[i - 1] * i % mod; } // for (int i = 1; i <= N; i++) { // ifp[i] = fpow(fp[i], mod - 2); // } ifp[N] = fpow(fp[N], mod - 2); for (int i(N - 1); i != 0; --i) { ifp[i] = ifp[i + 1] * (i + 1) % mod; } // cout << "wssb"; while (t--) { // scanf("%lld%lld", &a, &b); a = read(), b = read(); if (b + 1 < a) { // printf("0\n"); puts("0"); continue; } ll ans = fp[b] * fp[b + 1] % mod * ifp[b - a + 1] % mod; // printf("%lld\n", ans); write(ans), puts(""); } return 0; }