首页 > 代码库 > xtu read problem training 3 A - The Child and Homework

xtu read problem training 3 A - The Child and Homework

The Child and Homework

Time Limit: 1000ms
Memory Limit: 262144KB
This 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 Input

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

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.

 

Source

Codeforces 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