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 人评分
不容易系列2 (C语言代码)浏览:648 |
C二级辅导-分段函数 (C语言代码)浏览:851 |
IP判断 (C语言代码)浏览:920 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:582 |
C语言程序设计教程(第三版)课后习题12.2 (C语言代码)浏览:805 |
C语言程序设计教程(第三版)课后习题6.3 (Java代码)浏览:650 |
简单的a+b (C语言代码)浏览:644 |
简单的a+b (C语言代码)浏览:520 |
【简单计算】 (C语言代码)浏览:622 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:619 |