public static int a,n,m,max,ans=1;
public static int[]arr=new int[16];
public static int[]b=new int[16];
public static boolean[]v=new boolean[16];
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
while(a>0) {
n=sc.nextInt();
m=sc.nextInt();
for(int i=0;i<n;i++) {
arr[i]=sc.nextInt();
}
dfs(0);
System.out.println(max);
max=-Integer.MIN_VALUE;
a--;
}
}
public static void dfs(int x) {
if(x==m) {
ans=1;
for(int i=0;i<m;i++) {
ans*=b[i];
}
max=Math.max(max, ans);
return;
}
for(int i=0;i<n;i++) {
if(v[i]==false) {
v[i]=true;
b[i]=arr[i];
dfs(x+1);
v[i]=false;
}
}
}
0.0分
0 人评分
点我有惊喜!你懂得!浏览:1403 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:539 |
C语言训练-求矩阵的两对角线上的元素之和 (C语言代码)浏览:707 |
C二级辅导-等差数列 (C语言代码)浏览:1217 |
汽水瓶 (C语言代码)浏览:610 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:1523 |
C语言训练-排序问题<1> (C语言代码)浏览:601 |
简单的a+b (C语言代码)浏览:573 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:1420 |
WU-输出正反三角形 (C++代码)浏览:1021 |