• Codeforces Round #250 (Div. 2)A(英语学习)


    链接:http://codeforces.com/contest/437/problem/A

    A. The Child and Homework
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct.

    Fortunately the child knows how to solve such complicated test. The child will follow the algorithm:

    • If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great.
    • If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice).

    You are given a multiple-choice questions, can you predict child's choose?

    Input

    The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length.

    Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_".

    Output

    Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes).

    Sample test(s)
    input
    A.VFleaKing_is_the_author_of_this_problem
    B.Picks_is_the_author_of_this_problem
    C.Picking_is_the_author_of_this_problem
    D.Ftiasch_is_cute
    output
    D
    input
    A.ab
    B.abcde
    C.ab
    D.abc
    output
    C
    input
    A.c
    B.cc
    C.c
    D.c
    output
    B
    Note

    In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D.

    In the second sample, no choice is great, so the child will choose the luckiest choice C.

    In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.

    ******************************************************

    ……………………………………………………………………………………………………………………

    看了N久的题意,发现原来是英语词组不理解,英语水平太差

    A twice longer than B 表示 A >= 2 * B,A twice shorter than B表示 A * 2 <= B

    你知道吗???

     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <stdlib.h>
     4 #include <iostream>
     5 
     6 int main()
     7 {
     8     char str[105][105];
     9     int len[5];
    10     for(int i=1; i<=4; i++)
    11     {
    12         scanf("%s",str[i]);
    13         len[i]=strlen(str[i])-2;
    14     }
    15     int xy=0,dy=0;
    16     int flag=0;
    17     int ans=0;
    18     for(int i=1; i<=4; i++)
    19     {
    20         xy=0;dy=0;
    21         for(int j=1; j<=4; j++)
    22         {
    23             if(i != j)
    24             {
    25                 if(len[i]*2<=len[j])
    26                 {
    27                     xy++;
    28                 }
    29                 if(len[i]>=len[j]*2)
    30                 {
    31                     dy++;
    32                 }
    33             }
    34         }
    35         if(xy>2 || dy>2)
    36         {
    37             flag=i;
    38             ans++;
    39             //break;
    40         }
    41     }
    42     if(flag && ans == 1)
    43     {
    44         printf("%c
    ",flag+64);
    45     }
    46     else if(flag == 0 || ans != 1)
    47     {
    48         printf("C
    ");
    49     }
    50     return 0;
    51 }
  • 相关阅读:
    PDA固定资产条码管理系统软件-解决固定资产实物清查的瓶颈问题,大大提高清查效率
    互联网+下PDA移动智能手持POS超市收银开单软件
    搭建免费代理池
    解析库beautifulsoup
    爬取汽车之家新闻
    请求库之requests库
    网络状态码301与302
    正向代理与反向代理
    垃圾回收机制详解
    HTTP协议详解
  • 原文地址:https://www.cnblogs.com/ccccnzb/p/3908408.html
Copyright © 2020-2023  润新知