标签:格式 new while test turn res ati system rom
import java.util.Scanner;
/**
* @author 宗远
*
* 2017年3月13日
*/
public class Test__37 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int[] arr = new int[N];
for(int i=0; i<arr.length; i++)
arr[i] = sc.nextInt();
System.out.println(getResult(arr,0,K));
}
private static int getResult(int[] arr, int n, int k) {
if(k==0){
return getFromArray(arr, n, arr.length-1);
}else{
int result = 0;
for(int i=n; i<arr.length; i++){
int x = getFromArray(arr,n,i)*getResult(arr,i+1,k-1);
if(x>result){
result = x;
}
// System.out.println(result);
}
return result;
}
}
private static int getFromArray(int[] arr, int n, int i) {
int sum = 0;
while(n<=i){
sum = sum*10+arr[n];
n++;
}
return sum;
}
}
标签:格式 new while test turn res ati system rom
原文地址:http://www.cnblogs.com/czy960731/p/6661352.html