class="java"> package test; import java.util.HashMap; import java.util.Map; /** * @author QuarterLifeForJava * 极其简单初级的实现 */ public class Test { public static void main(String[] args) { int arry[] = {1,2,3,4,5,6}; int count = conditionTimes(arry); int rest = arry.length - count; if(rest == 0){//A(n)(n)种组合 int result = resultCount(arry.length,arry.length); System.out.println(result); }else{//A(n)(n-重复数字+1)除以A(重复数字)(1) int result = resultCount(count,arry.length)/resultCount(1,(rest+1)); System.out.println(result); } } public static int conditionTimes(int arry[]){ Map<Integer,Integer> map = new HashMap<Integer, Integer>(); for(int i=0;i<arry.length;i++){ map.put(arry[i], arry[i]); } return map.size(); } public static int resultCount(int start,int end){ int result = 1; for(int i=1;i<=start;i++){ result*=end; end--; } return result; } }