xtu read problem training 3 A - The Child and Homework

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   java   os   io   

The Child and HomeworkTime Limit: 1000msMemory Limit: 262144KBThis problem will be judged on CodeForces. Original ID: 437A
64-bit integer IO format: %I64d      Java class name: (Any)   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 InputInput
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
Hint

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.

 SourceCodeforces Round #250 (Div. 2) 
 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib>10 #include <string>11 #include <set>12 #define LL long long13 #define INF 0x3f3f3f3f14 using namespace std;15 struct node {16     char str[1000];17     int len,index;18 };19 bool cmp(const node &x,const node &y) {20     return x.len < y.len;21 }22 node p[4];23 int main() {24     int i,j;25     for(i = 0; i < 4; i++) {26         scanf("%s",p[i].str);27         p[i].len = strlen(p[i].str)-2;28         p[i].index = i;29     }30     sort(p,p+4,cmp);31     for(i = 1; i < 4; i++) {32         if(p[i].len < p[0].len*2) break;33     }34     for(j = 0; j < 3; j++)35         if(p[j].len*2 > p[3].len) break;36     if(i == 4 && j == 3 || i < 4 && j < 3) puts("C");37     else printf("%c\n",i == 4?p[0].index+‘A‘:p[3].index+‘A‘);38     return 0;39 }
View Code

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.