赞
踩
- public static int t1(int[] input){
- if(input.length > 8){
- return -1;
- }
- int minResult = Integer.MAX_VALUE;
- int minNum = Integer.MAX_VALUE;
- int maxNum = Integer.MIN_VALUE;
- for(int i = 0; i < input.length; i++){
- if(input[i] < minNum){
- minNum = input[i];
- }
- if(input[i]> maxNum){
- maxNum = input[i];
- }
- }
- for(int n = 1; n <= maxNum; n++){
- int count = 0;
- for(int i = 0; i < input.length; i++){
- if(input[i] % n == 0){
- count += (input[i]/n);
- } else {
- count += (input[i]/n + 1);
- }
- }
- if(count <= 8){
- minResult = (minResult > n)? n:minResult;
- }
- }
- return minResult;
- }
-
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- String[] inputValues = in.nextLine().split(" ");
- int[] input = new int[inputValues.length];
- for(int i = 0; i < inputValues.length; i++){
- input[i] = Integer.valueOf(inputValues[i]);
- }
- System.out.println(t1(input));
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。