• ARC107


    A
    (quad)简单推式子。

    code

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<ctime>
    #include<climits>
    #include<sstream>
    #include<fstream>
    using namespace std;
    #define int long long
    
    const int Mod = 998244353;
    
    signed main()
    {
        int a , b , c;
        cin >> a >> b >> c;
        int A = (a + 1) * a / 2;
        int B = (b + 1) * b / 2;
        int C = (c + 1) * c / 2;
        A %= Mod , B %= Mod , C %= Mod;
        int ans = A;
        ans *= B;
        ans %= Mod;
        ans *= C;
        ans %= Mod;
        cout << ans;
        return 0;
    }
    

    B
    (quad)简单枚举。

    code

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<ctime>
    #include<climits>
    #include<sstream>
    #include<fstream>
    using namespace std;
    #define int long long
    
    inline int num(int n , int x)
    {
        int fr = x - min(n , x - 1);
        int ne = min(n , x - 1);
        if(fr > ne)
        {
            return 0;
        }
        return ne - fr + 1;
    }
    
    signed main()
    {
        int n , k;
        cin >> n >> k;
        int ans = 0;
        for(register int i = 2 ; i <= 2 * n ; i++)
        {
            int ab = i;
            int cd = i - k;
            if(cd < 2 || cd > 2 * n)
            {
                continue;
            }
            ans += num(n , ab) * num(n , cd);
        }
        cout << ans;
        return 0;
    }
    

    C
    (quad)行和列可以分开,并且行列之间的交换可以传递。
    (quad)那么就并查集计数然后乘一下就好了。

    code

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<ctime>
    #include<climits>
    #include<sstream>
    #include<fstream>
    using namespace std;
    #define int long long
    
    const int N = 55;
    const int Mod = 998244353;
    
    struct Find
    {
        int fa[N];
    
        inline void clear()
        {
            for(register int i = 0 ; i < N ; i++)
            {
                fa[i] = i;
            }
        }
    
        inline int find(int x)
        {
            if(x == fa[x])
            {
                return fa[x];
            }
            else
            {
                return fa[x] = find(fa[x]);
            }
        }
    
        inline void modify(int x , int y)
        {
            int p = find(x) , q = find(y);
            fa[p] = q;
        }
    }f1,f2;
    
    int a[N][N];
    
    int s1[N] , s2[N];
    
    int t[N];
    
    inline void build()
    {
        int n = 50;
        t[0] = 1;
        for(register int i = 1 ; i <= n ; i++)
        {
            t[i] = t[i - 1] * i;
            t[i] %= Mod;
        }
    }
    
    signed main()
    {
        ios::sync_with_stdio(false);
        int n , k;
        cin >> n >> k;
        for(register int i = 1 ; i <= n ; i++)
        {
            for(register int j = 1 ; j <= n ; j++)
            {
                cin >> a[i][j];
            }
        }
        f1.clear() , f2.clear();
        for(register int x = 1 ; x <= n ; x++)
        {
            for(register int y = 1 ; y <= n ; y++)
            {
                bool xrq = 1;
                for(register int i = 1 ; i <= n ; i++)
                {
                    if(a[i][x] + a[i][y] > k)
                    {
                        xrq = 0;
                    }
                }
                if(xrq == 1)
                {
                    f1.modify(x , y);
                }
            }
        }
        for(register int x = 1 ; x <= n ; x++)
        {
            for(register int y = 1 ; y <= n ; y++)
            {
                bool xrq = 1;
                for(register int i = 1 ; i <= n ; i++)
                {
                    if(a[x][i] + a[y][i] > k)
                    {
                        xrq = 0;
                    }
                }
                if(xrq == 1)
                {
                    f2.modify(x , y);
                }
            }
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            s1[f1.find(f1.fa[i])]++;
            s2[f2.find(f2.fa[i])]++;
        }
        int ans1 = 1;
        int ans2 = 1;
        build();
        for(register int i = 1 ; i <= n ; i++)
        {
            ans1 *= t[s1[i]];
            ans1 %= Mod;
            ans2 *= t[s2[i]];
            ans2 %= Mod;
        }
        cout << ans1 * ans2 % Mod;
        return 0;
    }
    
    $——byquad wanwanjiuhao7744$
  • 相关阅读:
    2021hdu多校第二场补题
    ORACLE数据库之SQL语言基础
    EXCEL应用
    element-ui闭坑
    题解 CF1559E 【Mocha and Stars】
    题解 CF1530D 【Secret Santa】
    题解 CF1209E2 【Rotate Columns (hard version)】
    题解 CF761E 【Dasha and Puzzle】
    题解 UVA437 【巴比伦塔 The Tower of Babylon】
    题解 P6100 【[USACO19FEB]Painting the Barn G】
  • 原文地址:https://www.cnblogs.com/wanwanjiuhao7744/p/15130351.html
Copyright © 2020-2023  润新知