2018搜狐秋招笔试题2 最少包裹数

package SouHu;

import java.util.Scanner;

public class SoHuWrapProduct {

    public int solve(int[] arr){
        int count=0;
        count+=arr[5];
        count+=arr[4];

        int one=11*arr[4];

        count+=arr[3];
        int two=5*arr[3];

        //转化3
        count+=arr[2]/4;
        if(arr[2]%4!=0) count++;

        if(arr[2]%4==1){
            two+=5;
            one+=7;
        }
        if(arr[2]%4==2){
            two+=3;
            one+=6;
        }
        if(arr[2]%4==3){
            two+=1;
            one+=5;
        }

        if(arr[1]<=two){
            one=one+(two-arr[1])*4;
        }else{
            count+=(arr[1]-two)/9;
            if((arr[1]-two)%9!=0){
                count++;
                one+=(((arr[1]-two)%9)*4);
            }
        }

        if(arr[0]<=one){
            return count;
        }else{
            count+=(arr[0]-one)/36;
            if((arr[0]-one)%36!=0) count++;
            return count;
        }
    }

    public static void main(String[] args){
        SoHuWrapProduct s=new SoHuWrapProduct();
        Scanner in=new Scanner(System.in);

        int[] arr=new int[6];
        while(in.hasNext()){
            for(int i=0;i<6;i++) arr[i]=in.nextInt();
            System.out.println(s.solve(arr));
        }
    }



}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值