zoukankan      html  css  js  c++  java
  • Codeforces 437A The Child and Homework

    题目链接:Codeforces 437A The Child and Homework

    少看了一个条件,最后被HACK掉到203名,要不然就冲到100多一点了==。。

    做这个题收获最大的是英语,A twice longer than B 表示 A >= 2 * B,A twice shorter than B表示 A * 2 <= B。

     

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    
    using namespace std;
    
    struct AA
    {
        int a, i;
    };
    
    int cmp(AA b, AA c)
    {
        return b.a < c.a;
    }
    
    int main()
    {
        char a[120], b[120], c[120], d[120];
        scanf("%s%s%s%s", a, b, c, d);
        AA aa[4];
        aa[0].a = strlen(a) - 2;
        aa[0].i = 0;
        aa[1].a = strlen(b) - 2;
        aa[1].i = 1;
        aa[2].a = strlen(c) - 2;
        aa[2].i = 2;
        aa[3].a = strlen(d) - 2;
        aa[3].i = 3;
        sort(aa, aa + 4, cmp);
        int vis = 0;
        int k;
        if(aa[0].a * 2 <= aa[3].a && aa[0].a * 2 <= aa[2].a && aa[0].a * 2 <= aa[1].a)
        {
            vis++;
            k = aa[0].i;
        }
        if(aa[3].a >= aa[0].a * 2 && aa[3].a >= aa[1].a * 2 && aa[3].a >= aa[2].a * 2)
        {
            vis++;
            k = aa[3].i;
        }
        if(vis == 1)
            cout << (char)(k + 'A') << endl;
        else
            cout << "C" << endl;
        return 0;
    }
    

  • 相关阅读:
    break return continue
    爬虫---请求
    pycharm加开头注释
    爬虫---入门
    pip
    XML基础
    英语
    布局
    adobe
    StackOverflow
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4065461.html
Copyright © 2011-2022 走看看