标签:des style blog http color java os io
Fortunately the child knows how to solve such complicated test. The child will follow the algorithm:
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.
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 long 13 #define INF 0x3f3f3f3f 14 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 }
xtu read problem training 3 A - The Child and Homework,布布扣,bubuko.com
xtu read problem training 3 A - The Child and Homework
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/crackpotisback/p/3891599.html