链接:http://codeforces.com/contest/437/problem/A
1 second
256 megabytes
standard input
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?
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 "_".
Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes).
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
D
A.ab
B.abcde
C.ab
D.abc
C
A.c
B.cc
C.c
D.c
B
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
你知道吗???
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream> int main()
{
char str[][];
int len[];
for(int i=; i<=; i++)
{
scanf("%s",str[i]);
len[i]=strlen(str[i])-;
}
int xy=,dy=;
int flag=;
int ans=;
for(int i=; i<=; i++)
{
xy=;dy=;
for(int j=; j<=; j++)
{
if(i != j)
{
if(len[i]*<=len[j])
{
xy++;
}
if(len[i]>=len[j]*)
{
dy++;
}
}
}
if(xy> || dy>)
{
flag=i;
ans++;
//break;
}
}
if(flag && ans == )
{
printf("%c\n",flag+);
}
else if(flag == || ans != )
{
printf("C\n");
}
return ;
}