Sample Output
10Hint
样例输出只是输出格式参考穷举即可,也可以写14个for循环来穷举,那就台low了.可以用二进制来替换穷举。public class T6 { static int[] data=new int[15]; public static void main(String[] args) { int m=16384;//Math.pow(2, 14); int count=0; for (int i = 0; i <= m; i++) { int sum=2; int a=0; String b=""; getEr(i); for (int j = 0; j < data.length; j++) { if(data[j]==1){ sum=sum*2; a++; b=b+"a"; } else{ sum=sum-1; b=b+"b"; } } if(sum==0&&a==5){ //System.out.PRintln(a+" "+b); count++; } } System.out.println(count); } private static void getEr(int i) { data=new int[15]; int k=0; while(i>0){ data[k]=i%2; i=i/2; k++; } }}
新闻热点
疑难解答