来自澳大利亚的兵


私信TA

用户名:zhangjun678

访问量:2961

签 名:

等  级
排  名 244
经  验 5875
参赛次数 0
文章发表 28
年  龄 0
在职情况 学生
学  校 djtu
专  业 计算机科学与技术

  自我简介:

喜欢数学,编程小白

TA的其他文章

解题思路: 箱子严格按由大到小装       6- 5-4-3-2-1                        

                                                                  剩余空间装箱

                       占用个数                    1*1      2*2      3*3    4*4    5*5   6*6
         6*6         1                                0         0          0        0        0       0

         5*5         1                                11        0          0        0        0       0

         4*4         1                                0         5          0        0        0       0

         3*3     %4==0                          0         0          0        0        0       0

         3*3     %4==1                          7         5          0        0        0       0

         3*3     %4==2                           6        3         0        0        0       0

         3*3     %4==3                          5         1          0        0        0       0

参考代码:

import java.util.Scanner;

public class  Main{

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        while (true){

            int box1=scanner.nextInt();

            int box2=scanner.nextInt();

            int box3=scanner.nextInt();

            int box4=scanner.nextInt();

            int box5=scanner.nextInt();

            int box6=scanner.nextInt();

            if(box1==0&&box2==0&&box3==0&&box4==0&&box5==0&&box6==0)

                break;

            int number=0;

            int number3=box3/4+1;

            int remain3=box3%4;

            int empty2=0;

            int empty1=0;

            switch (remain3){

                case 1:

                    empty2=5+box4*5;

                    empty1=11*box5+7;

                    break;

                case 2:

                    empty2=3+box4*5;

                    empty1=6+11*box5;

                    break;

                case 3:

                    empty2=1+box4*5;

                    empty1=11*box5+5;

                    break;

                case 0:

                    empty2=box4*5;

                    empty1=box5*11;

                    number3=number3-1;

                    break;

            }

           if(empty2>=box2){

               box2=0;

           }

           else

               box2=box2-empty2;

           int number2=box2/9+1;

           int remain2=box2%9;

           if(remain2==0)

               number2--;

           empty1=36-remain2*4+empty1;

            if(empty1>=box1){

                number=box6+box4+box5+number3+number2;

            }

            else

                number=box6+box4+box5+number3+number2+(box1-empty1)/36+1;

            System.out.println(number);

        }

    }

}


 

0.0分

0 人评分

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

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

代码解释器

代码纠错

SQL生成与解释

  评论区