A. The Child and Homework

 

http://codeforces.com/contest/437/problem/A

 

 1 import java.util.ArrayList;
 2 import java.util.Scanner;
 3 
 4 public class Main {
 5 
 6     public static void main(String[] args) {
 7         Scanner in = new Scanner(System.in);
 8         while (in.hasNext()){
 9             int[]len=new int[4];
10             int[]min=new int[4];
11             int[]max=new int[4];
12             for (int i = 0; i < 4; i++) {
13                 String s=in.nextLine();
14                 while (s.length()==0)s=in.nextLine();
15                 len[i]=s.length()-2;
16             }
17             for (int i = 0; i < 4; i++) {
18                 for (int j = 0; j < 4; j++) {
19                     if (j==i)continue;
20                     if (len[j]>=len[i]*2)min[i]++;
21                     if (len[j]*2<=len[i])max[i]++;
22                 }
23             }
24             ArrayList<Integer>al=new ArrayList<>();
25             for (int i = 0; i < 4; i++) if (min[i]==3||max[i]==3)al.add(i);
26             if (al.size()!=1) System.out.println("C");
27             else System.out.println((char)(al.get(0)+'A'));
28         }
29     }
30 }

 

上一篇:详述throw和throws


下一篇:Python_HomeWork_Day01_1