zoukankan      html  css  js  c++  java
  • P6561 [SBCOI2020] 人

    题目链接

    自己写给自己看的,题解看这里

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    #define int long long
    #define ll long long
    #define pb push_back
    const int maxn = 1e6 + 10;
    const int mod = 998244353;
    using namespace std;
    int fac[maxn];
    int inv[maxn];
    ll pow_mod(ll x,ll n,ll mod){
        ll res=1;
        while(n)
        {
            if(n&1) res = res * x % mod;
            x= x * x % mod;
            n >>= 1;
        }
        return res;
    }
    void init()
    {
        inv[0] = inv[1] = fac[0] = 1;
        for(int i = 1 ; i < maxn ; i ++){
            fac[i] = fac[i - 1] * i % mod;
        }
        inv[maxn - 1] = pow_mod(fac[maxn - 1] , mod - 2 , mod);
        
        for(int i = maxn - 2 ; i > 1 ; i --){
            inv[i] = inv[i + 1] * (i + 1) % mod;
        }
    }
    int C(int n , int m)
    {
        if(n < m)swap(n , m); 
        return fac[n] * inv[m] % mod * inv[n - m] % mod;
    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t;
        cin >> t;
        init();
    
        while(t --){
            int n , a , b;
            cin >> n >> a >> b;
            if(a + b > n){
                cout << 0 << '
    ';
            }
            else{
                int x = C(n - a , b) % mod;
                int y = C(n - b , a) % mod;
    
                cout << x * y % mod << '
    ';
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    GitHub Interesting Collection
    使用 CSS3 Flexible Boxes 布局
    消失的属性
    浅谈 JavaScript 模块化编程
    为你的 Javascript 加点咖喱
    软件测试
    osi七层模型
    3_Hydra(爆破神器)
    2_NC(瑞士军刀)
    1_HTTP协议详解
  • 原文地址:https://www.cnblogs.com/GoodVv/p/14290707.html
Copyright © 2011-2022 走看看