alibba


私信TA

用户名:dotcpp0733017

访问量:122

签 名:

等  级
排  名 27833
经  验 499
参赛次数 0
文章发表 2
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区