分享到:

回答下面10道问题,每道题只有一个正确答案。

1、第一个答案是B的问题是?
A) 2    B) 3    C)4    D) 5    E)6
2、唯一的连续两个具有相同答案的是?
A) 2,3    B)3,4    C)4,5    D)5,6    E)6,7
3、本问题答案和哪个问题答案相同?
A)1    B)2    C)4    D)7    E)6
4、答案是A的问题的个数?
A)0    B)1    C)2    D)3    E)4
5、本问题答案和哪个问题相同?
A)10    B)9    C)8    D)7    E)6
6、答案是A的问题的个数和答案是什么的问题的个数相同?
A)B    B)C    C)D    D)E    E)以上都不是
7、按照字母顺序本问题的答案和下一个问题的答案相差几个字母?
A)4    B)3    C)2    D)1    E)0    (注:A和B相差一个字母)
8、答案是元音字母的问题的个数?
A)2    B)3    C)4    D)5    E)6    (注: A和E是元音字母)
9、答案是辅音字母的个数?
A)是一个质数    B)是一个阶乘数    C)是一个平方数    D)是一个立方数    E)是5的倍数
10、本问题的答案是:
A)A    B)B    C)C    D)D    E)E

import java.util.HashMap;
public class Test {
  public static void main(String args[]) {
    // 初始化答案
    int[] ans = new int[10];
    // 第三题的答案组
    int[] ans3 = { 1, 2, 4, 7, 6 };
    // 第九题的答案组
    int[] ans9 = { 7, 6, 4, 8, 5 };
    //HashMap对应数字和答案标号
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("0", "A");
    map.put("1", "B");
    map.put("2", "C");
    map.put("3", "D");
    map.put("4", "E");
    // 循环问题
    for (ans[0] = 0; ans[0] <= 4; ans[0]++) {
      for (ans[1] = 0; ans[1] <= 4; ans[1]++) {
        for (ans[2] = 0; ans[2] <= 4; ans[2]++) {
          for (ans[3] = 0; ans[3] <= 4; ans[3]++) {
            for (ans[4] = 0; ans[4] <= 4; ans[4]++) {
              for (ans[5] = 0; ans[5] <= 4; ans[5]++) {
                for (ans[6] = 0; ans[6] <= 4; ans[6]++) {
                  for (ans[7] = 0; ans[7] <= 4; ans[7]++) {
                    for (ans[8] = 0; ans[8] <= 4; ans[8]++) {
                      for (ans[9] = 0; ans[9] <= 4; ans[9]++) {
                        // 计算答案个数
                        // 初始化答案个数
                        int[] ansnum = { 0, 0, 0, 0, 0 };
                        // A
                        for (int n = 0; n <= 9; n++) {
                          if (ans[n] == 0)
                            ansnum[0]++;
                        }
                        // B
                        for (int n = 0; n <= 9; n++) {
                          if (ans[n] == 1)
                            ansnum[1]++;
                        }
                        // C
                        for (int n = 0; n <= 9; n++) {
                          if (ans[n] == 2)
                            ansnum[2]++;
                        }
                        // D
                        for (int n = 0; n <= 9; n++) {
                          if (ans[n] == 3)
                            ansnum[3]++;
                        }
                        // E
                        for (int n = 0; n <= 9; n++) {
                          if (ans[n] == 4)
                            ansnum[4]++;
                        }
                        // 第一题
                        if (ans[ans[0] + 1] == 1) {
                          // 第二题
                          if (ans[ans[1] + 1] == ans[ans[1] + 2]
                              && ans[ans[1] + 2] != ans[ans[1] + 3]
                              && ans[ans[1] + 3] != ans[ans[1] + 4]
                              && ans[ans[1] + 4] != ans[ans[1] + 5]) {
                            // 第三题
                            if (ans[2] == ans[ans3[ans[2]] - 1]) {
                              // 第四题
                              if (ans[3] == ansnum[0]) {
                                // 第五题
                                if (ans[4] == ans[9 - ans[4]]) {
                                  // 第六题
                                  if ((ans[5] != 4
                                          && ansnum[0] == ansnum[ans[5] + 1])
                                      ^ (ans[5] == 4
                                          && ansnum[0] != ansnum[1]
                                          && ansnum[0] != ansnum[2]
                                          && ansnum[0] != ansnum[3]
                                          && ansnum[0] != ansnum[4])) {
                                    // 第七题
                                    if (Math.abs(ans[6]
                                        - ans[7]) == 4 - ans[6]) {
                                      // 第八题
                                      if (ans[7] + 2 == ansnum[0]
                                          + ansnum[4]) {
                                        // 第九题
                                        if (ans9[ans[8]] == ansnum[1]
                                            + ansnum[2]
                                            + ansnum[3]) {
                                          // 第十题
                                          if (ans[6] != ans[7]
                                              && ans[7] != ans[8]
                                              && ans[8] != ans[9]) {
                                            System.out
                                                .println(map.get(ans[0] + "")
                                                    + map.get(ans[1] + "")
                                                    + map.get(ans[2] + "")
                                                    + map.get(ans[3] + "")
                                                    + map.get(ans[4] + "")
                                                    + " "
                                                    + map.get(ans[5] + "")
                                                    + map.get(ans[6] + "")
                                                    + map.get(ans[7] + "")
                                                    + map.get(ans[8] + "")
                                                    + map.get(ans[9] + ""));
                                          }
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

运行结果:CDEBE EDCBA

另附上一位大神手算的过程:

1)考虑7、8;则8的答案只能为A、E、C;从而9的答案只能为:D、C、B;7的答案在8是E的时侯不定;另外两种情况下是确定的C或者D。

2)考虑2:A不可能,否则123矛盾;如果选B,则1234的答案为ABCC;和789的三种情况分别比对,发现都不适合。

3)跳到3:很容易看出,由于2的AB都不可能,则3的ABC都不可能;如果为D,则7的答案也为D,那么789的答案确定,再推其他几个答案,都不适合。所以3的答案只能为E。则6的答案为E。

4)再回到1,由于2、3、6的答案都不可能是B,则只可能选C或者D,分别代入,很快可以排除D,选C。

5)后面的就好推了。