3 条题解

  • 0
    @ 2023-3-25 17:37:47
    #include <bits/stdc++.h>
    using namespace std;
    const long long MOD = 998244353;
    
    long long MODP(long long a, long long b)
    {
        long long c = 1;
        while (b)
        {
            if (b & 1) c = c * a % MOD;
            a = a * a % MOD;
            b >>= 1;
        }
        return c;
    }
    
    long long INV(long long a) { return MODP(a, MOD - 2); }
    
    int main(int argc, char *argv[])
    {
        cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
        int cases;
        long long n, a, b, c;
        cin >> cases;
        assert(1 <= cases && cases <= 100);
        for (int cs = 1; cs <= cases; cs++)
        {
            cin >> n >> a >> b >> c;
            assert(1 <= n && n <= 100000);
            assert(1 <= a && a <= n - 1);
            assert(1 <= b && b <= n - 2);
            assert(0 <= c && c < min(a, b));
            long long p = n * (a - c) - a;
            long long q = n * (n - b - 1);
            long long g = __gcd(p, q);
            p /= g, q /= g;
            cout << (p % MOD) * INV(q % MOD) % MOD << '\n';
        }
        return 0;
    }
    
    

    信息

    ID
    143
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    递交数
    85
    已通过
    20
    上传者