建行笔试题,最少补给品问题

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] s = str.split(" ");
        Integer m =  Integer.valueOf(s[0]);
        Integer n =  Integer.valueOf(s[1]);

       // System.out.println(m+" "+n);
        int min = getMin(m, n);
        System.out.println(min);

    }

    public static int  getMin(Integer m,Integer n){
      /*  // 每层能覆盖的点
        Integer overPointPerLayer ;

        Integer LayerCounts;

        if (m%2==0){
            overPointPerLayer = m/2;
        }else {
            overPointPerLayer = m / 2 + 1;
        }


        // 获得覆盖层数
        if (n % 2 == 0){
            LayerCounts = n / 2;
        }else {
            LayerCounts = n / 2 + 1;
        }
        return overPointPerLayer * LayerCounts;*/

      return ((n%2==0? n/2 :n/2+1)*(m%2==0? m/2 :m/2+1));
    }
}

 

你可能感兴趣的:(算法)