解题思路: 箱子严格按由大到小装 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语言代码)浏览:1153 |
C语言训练-大、小写问题 (C语言代码)浏览:724 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:604 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:683 |
Tom数 (C语言代码)浏览:492 |
1051(奇了怪了)浏览:646 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:511 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:567 |
C语言训练-自守数问题 (C语言代码)浏览:740 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:658 |