コード例 #1
0
ファイル: I.java プロジェクト: Betillo77/in-silico
 public static void main(String[] args) {
   for (int i = 2; i < 10100; i++) {
     for (int j = 2; j < i; j++) if ((i % j) == 0) primos[i] = true;
   }
   for (int i = 2; i < 10100; i++) {
     ArrayList<Integer> fact = new ArrayList<Integer>();
     for (int j = 2; j <= i; j++) {
       if ((!primos[j]) && ((i % j) == 0)) fact.add(j);
     }
     factores[i] = fact;
   }
   Scanner sc = new Scanner();
   while (!sc.endLine()) {
     int nn = sc.nextInt();
     int resO = 0;
     int resE = 0;
     int resI = 0;
     for (int i = 0; i < nn; i++) {
       char c = sc.next().charAt(0);
       int val = 0;
       if (c == 'O') val = IMAGINARY;
       else if (c == 'E') val = ODD;
       else val = EVEN;
       n = sc.nextInt();
       for (int j = 0; j < 10100; j++) for (int k = 0; k < 3; k++) dp[j][k] = null;
       Respuesta r = dp(n, val);
       if (r.o == Integer.MAX_VALUE) resO += n;
       else resO += r.o;
       if (r.e == Integer.MAX_VALUE) resE += n;
       else resE += r.e;
       if (r.i == Integer.MAX_VALUE) resI += n;
       else resI += r.i;
     }
     System.out.println(resO + " " + resE + " " + resI);
   }
 }