zoukankan      html  css  js  c++  java
  • Codeforces Round #294 (Div. 2)

    水 A. A and B and Chess

    /*
        水题
    */
    #include <cstdio>
    #include <algorithm>
    #include <iostream>
    #include <cstring>
    #include <string>
    using namespace std;
    
    const int maxn = 1e6 + 10;
    int a[maxn];
    
    int main(void)
    {
        //freopen ("A.in", "r", stdin);
    
        string s1;
        int suma = 0;    int sumb = 0;
        for (int i=1; i<=8; ++i)
        {
            cin >> s1;
            for (int j=0; s1[j]!=''; ++j)
            {
                if (s1[j] == '.')    continue;
                else if (s1[j] == 'Q')    suma += 9;
                else if (s1[j] == 'R')    suma += 5;
                else if (s1[j] == 'B')    suma += 3;
                else if (s1[j] == 'N')    suma += 3;
                else if (s1[j] == 'P')    suma += 1;
                else if (s1[j] == 'q')    sumb += 9;
                else if (s1[j] == 'r')    sumb += 5;
                else if (s1[j] == 'b')    sumb += 3;
                else if (s1[j] == 'n')    sumb += 3;
                else if (s1[j] == 'p')    sumb += 1;
            }
        }
    
        if (suma > sumb)    cout << "White" << endl;
        else if (suma < sumb)    cout << "Black" << endl;
        else    cout << "Draw" << endl;
    
        return 0;
    }
    

    水 B. A and B and Compilation Errors

    题意:三组数列,依次少一个,找出少了的两个数

    思路:

    1. 三次排序,逐个对比(如果没找到,那个数在上一个数列的末尾)
    2. 求和做差,最简单!

    #include <cstdio>
    #include <algorithm>
    #include <iostream>
    using namespace std;
    
    const int maxn = 1e5 + 10;
    int a[maxn];
    int b[maxn];
    int c[maxn];
    
    int main(void)
    {
        //freopen ("B.in", "r", stdin);
    
        int n, x, y;
    
        while (~scanf ("%d", &n))
        {
            x = y = 0;
            for (int i=1; i<=n; ++i)
            {
                scanf ("%d", &a[i]);
            }
            sort (a+1, a+1+n);
            for (int i=1; i<=n-1; ++i)
            {
                scanf ("%d", &b[i]);
            }
            sort (b+1, b+1+n-1);
            for (int i=1; i<=n-1; ++i)
            {
                if (a[i] == b[i])    continue;
                else
                {
                    x = a[i];
                    break;
                }
            }
            if (x == 0)        x = a[n];
            for (int i=1; i<=n-2; ++i)
            {
                scanf ("%d", &c[i]);
            }
            sort (c+1, c+1+n-2);
            for (int i=1; i<=n-2; ++i)
            {
                if (b[i] == c[i])    continue;
                else
                {
                    y = b[i];
                    break;
                }
            }
            if (y == 0)        y = b[n-1];
            printf ("%d
    %d
    ", x, y);
    
        }
    
        return 0;
    }
    
    /*
    #include <cstdio>
    #include <algorithm>
    #include <iostream>
    using namespace std;
    
    const int maxn = 1e5 + 10;
    int a[maxn];
    int b[maxn];
    int c[maxn];
    int suma, sumb, sumc;
    
    int main(void)
    {
        //freopen ("B.in", "r", stdin);
    
        int n;
    
        while (~scanf ("%d", &n))
        {
            suma = sumb = sumc = 0;
            for (int i=1; i<=n; ++i)
            {
                scanf ("%d", &a[i]);    suma += a[i];
            }
            for (int i=1; i<=n-1; ++i)
            {
                scanf ("%d", &b[i]);    sumb += b[i];
            }
            for (int i=1; i<=n-2; ++i)
            {
                scanf ("%d", &c[i]);    sumc += c[i];
            }
    
            printf ("%d
    %d
    ", suma - sumb, sumb - sumc);
        }
    
        return 0;
    }
    */
    

    构造 C. A and B and Team Training

    题意:方案:高手1和菜鸟2 或者 高手2菜鸟1 三人组队求最大组队数
    思路:

    1. 高手加菜鸟每三个分开,在n,m的数字之内
    2. 高手多,高手2;菜鸟多,菜鸟2 比较好理解

    #include <cstdio>
    #include <algorithm>
    using namespace std;
    
    int main(void)
    {
        //freopen ("C.in", "r", stdin);
    
        int n, m;
    
        while (~scanf ("%d%d", &n, &m))
        {
            int ans = (n + m) / 3;
            ans = min (ans, n);
            ans = min (ans, m);
            printf ("%d
    ", ans);
        }
    
        return 0;
    }
    
    /*
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    
    int main(void)
    {
        //freopen ("C.in", "r", stdin);
    
        int n, m;
    
        while (~scanf ("%d%d", &n, &m))
        {
            int cnt = 0;
            while (n && m && (n + m) >= 3)
            {
                if (n >= m)
                {
                    n -= 2;        m -= 1;
                }
                else
                {
                    n -=1;        m -= 2;
                }
                cnt++;
            }
    
            printf ("%d
    ", cnt);
    
        return 0;
    }
    */
    

      

    编译人生,运行世界!
  • 相关阅读:
    win7安装ruby on rails开发环境
    ZOJ 3802 Easy 2048 Again 像缩进DP
    【IOS】 遍历info 所有内容 &amp;&amp; 唯一的节能设备UUID
    IBM即将倒闭,微软也从崩溃18个月
    F4107Usart数据处理程序
    Samza/KafkaAnalysizing
    krpano音量控制(我们已经转移到krpano中国网站 krpano360.com)
    使用Visual Studio创建映像向导(Image Sprite)——Web Essential
    C#控件系列--文本类控件
    Java Swing 探索(一)LayoutManager
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4366782.html
Copyright © 2011-2022 走看看