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 }
代码君

相关文章:

  • 2021-07-27
  • 2021-08-19
  • 2022-02-28
  • 2021-12-24
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-19
  • 2021-08-08
  • 2022-01-29
  • 2021-12-05
  • 2021-11-08
  • 2021-06-14
  • 2022-02-11
相关资源
相似解决方案