import java.util.HashSet; public class Main1 { public static int ys = 0; public static int ys2 = 0; public static int N = 10; public static int[] a = new int[13]; public static int[]visit = new int[13]; public static void main(String[] args) { dfs1(0); dfs2(0, 0); System.out.println(ys); System.out.println(ys2); } public static void dfs1(int cnt) { // 这样的是全排列: A(12,5) if(cnt == 5) { ys++; return ; } for(int i = 1; i <= 12; i++) { if(visit[i] == 0) { visit[i] = 1; a[cnt] = i; dfs1(cnt + 1); visit[i] = 0; } } } public static void dfs2(int index, int cnt) { // 这样的是不要顺序: C(12,5) if(cnt == 5) { ys2++; return ; } for(int i = index + 1; i <= 12; i++) { a[cnt] = i; dfs2(i, cnt + 1); } } }