A. The Child and Homework
注意仔细读题,WA了好多次,=_=
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 const int maxn = 110; 7 8 char s[4][maxn]; 9 int l[4], r[4]; 10 11 bool cmp(int a, int b) { return l[a] < l[b]; } 12 13 int main() 14 { 15 //freopen("in.txt", "r", stdin); 16 17 for(int i = 0; i < 4; i++) r[i] = i; 18 for(int i = 0; i < 4; i++) scanf("%s", s[i]); 19 for(int i = 0; i < 4; i++) { l[i] = strlen(s[i]); l[i] -= 2; } 20 sort(r, r + 4, cmp); 21 22 int ans = -1; 23 if(l[r[0]] * 2 <= l[r[1]]) ans = r[0]; 24 if(l[r[3]] >= l[r[2]] * 2) { if(ans == -1) ans = r[3]; else ans = 2; } 25 if(ans == -1) ans = 2; 26 27 printf("%c\n", 'A' + ans); 28 29 return 0; 30 }