链接:http://codeforces.com/contest/437/problem/A
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
你知道吗???
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 }