zoukankan      html  css  js  c++  java
  • ARC115

    A
    (quad)首先确定两个人正确个数相同相同存在于去掉选择相同的题目之后如果剩下题目个数为偶数。
    (quad)反而反之,为奇数个则不同。
    (quad)因为存在传递性,即和A和B相同,B和C相同则A和C相同,故可分成两类然后直接乘。

    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 = 1e5 + 10;
    
    int n , m;
    
    inline bool same(string a , string b)
    {
        bool ans = 1;
        for(register int i = 0 ; i < m ; i++)
        {
            if(a[i] != b[i])
            {
                ans ^= 1;
            }
        }
        return ans;
    }
    
    string c;
    
    signed main()
    {
        ios::sync_with_stdio(false);
        cin >> n >> m;
        int f1 = 0 , f2 = 0;
        for(register int i = 1 ; i <= m ; i++)
        {
            c += "0";
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            string s;
            cin >> s;
            if(same(s , c))
            {
                f1++;
            }
            else
            {
                f2++;
            }
        }
        cout << f1 * f2;
        return 0;
    }
    

    B
    (quad)首先我们可以通过行列来判断A和B是否自相矛盾,顺便得到(A_i,B_i)(A_1,B_1)的相对数量关系。
    (quad)我们再将A,B分别加上它们中的最小负值的绝对值(如果没有则不加),这样就构造出了初步的数列。
    (quad)最后我们算出此时(A_1+B_1)(C_{1,1})的差值,如果为负也不行,然后再随便找A或者B加上这个差值,输出即可。

    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;
    
    const int N = 510;
    
    int c[N][N];
    
    int a[N];
    int b[N];
    
    signed main()
    {
        int n;
        cin >> n;
        for(register int i = 1 ; i <= n ; i++)
        {
            for(register int j = 1 ; j <= n ; j++)
            {
                cin >> c[i][j];
            }
        }
        if(n == 1)
        {
            cout << "Yes" << endl;
            cout << 0 << endl << c[1][1];
            return 0;
        }
        bool A = 1;
        for(register int i = 2 ; i <= n ; i++)
        {
            a[i] = c[1][i] - c[1][1];
        }
        for(register int i = 2 ; i <= n ; i++)
        {
            for(register int j = 2 ; j <= n ; j++)
            {
                if(c[i][j] - c[i][1] != a[j])
                {
                    A = 0;
                }
            }
        }
        if(A == 0)
        {
            cout << "No";
            return 0;
        }
        bool B = 1;
        for(register int i = 2 ; i <= n ; i++)
        {
            b[i] = c[i][1] - c[1][1];
        }
        for(register int i = 2 ; i <= n ; i++)
        {
            for(register int j = 2 ; j <= n ; j++)
            {
                if(c[j][i] - c[1][i] != b[j])
                {
                    B = 0;
                }
            }
        }
        if(B == 0)
        {
            cout << "No";
            return 0;
        }
        int mina = INT_MAX , minb = INT_MAX;
        for(register int i = 1 ; i <= n ; i++)
        {
            mina = min(mina , a[i]);
            minb = min(minb , b[i]);
        }
        if(mina < 0)
        {
            mina = -mina;
        }
        else
        {
            mina = 0;
        }
        if(minb < 0)
        {
            minb = -minb;
        }
        else
        {
            minb = 0;
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            a[i] += mina;
            b[i] += minb;
        }
        if(a[1] + b[1] > c[1][1])
        {
            cout << "No";
            return 0;
        }
        int d = c[1][1] - (a[1] + b[1]);
        for(register int i = 1 ; i <= n ; i++)
        {
            a[i] += d;
        }
        cout << "Yes" << endl;
        for(register int i = 1 ; i <= n ; i++)
        {
            cout << b[i] << " ";
        }
        cout << endl;
        for(register int i = 1 ; i <= n ; i++)
        {
            cout << a[i] << " ";
        }
        return 0;
    }
    

    C
    (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;
    
    const int N = 1e5 + 10;
    
    int a[N];
    
    signed main()
    {
        ios::sync_with_stdio(false);
        int n;
        cin >> n;
        for(register int i = 1 ; i <= n ; i++)
        {
            a[i] = 1;
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            for(register int j = i + i ; j <= n ; j += i)
            {
                if(a[j] == a[i])
                {
                    a[j]++;
                }
            }
        }
        for(register int i = 1 ; i <= n ; i++)
        {
            cout << a[i] << " ";
        }
        return 0;
    }
    
    $——byquad wanwanjiuhao7744$
  • 相关阅读:
    17. 偏函数
    16. 装饰器
    vim详解
    linux用户管理sudo 磁盘分区
    linux用户管理
    linux文件与目录(四)
    linux特殊权限
    linux文件和目录(二)
    linux文件和目录
    配置网络
  • 原文地址:https://www.cnblogs.com/wanwanjiuhao7744/p/15091730.html
Copyright © 2011-2022 走看看