解题思路: 箱子严格按由大到小装 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 人评分
C语言训练-排序问题<1> (C语言代码)浏览:588 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1090 |
简单的a+b (C语言代码)浏览:764 |
买不到的数目 (C++代码)浏览:909 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:1071 |
C语言程序设计教程(第三版)课后习题1.5 (C++代码)浏览:778 |
小明A+B (C语言代码)浏览:1316 |
简单的a+b (C语言代码)浏览:600 |
A+B for Input-Output Practice (III) (C语言代码)浏览:592 |
简单的a+b (C语言代码)浏览:641 |