「CF437A」The Child and Homework

2014年6月2日2,3580

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

output

input

output

input

output

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.

题意 orzwyl8899

很久以前,一个小朋友有一份含有n个单项选择题的家庭作业。一个单项选择题含有A,B,C,D四个选项,每个选项都含有一句描述,他需要从中找出唯一正确的那个。
幸运的是他知道如何解决这个复杂的问题。他将会遵循如下的算法:
1. 如果有某个选项的描述的长度比其他描述短至少一半,或至少长一倍,他会认为这个选项是”好的”;
2. 如果四个选项中恰有一个是”好的”,他就会选择它;否则他会选C(他认为这是最幸运的选项)。
现在你拿到了这个单项选择题,你能预测他做出的选择吗?
Input
第一行以”A.”开头(不含引号),然后紧跟着A选项的描述。接下来的三行按照B,C,D的顺序以同样的格式描述其他三个选项。请注意,选项是紧跟着”X.”这个前缀之后的,所以计算描述的长度时前缀不应被算在里面。
每个描述非空且包含至多100个字符,每个字符可能会是大写或小写英文字母,或是”_”。
Output
输出一个字母(A,B,C,D中的一个)。

题解

我直接模拟了。。。

 

avatar
  Subscribe  
提醒