1017:装箱问题百炼oj

    xiaoxiao2021-03-25  86

    #include<iostream> #include<stdio.h> const int len = 6; using namespace std; int main() { int num[len]; while (1) { int sum = 0; for (int i = 0; i < len; i++) { cin >> num[i]; sum += num[i]; } if (sum == 0) break; int res = num[5] + num[4] + num[3] + (num[2] + 3) / 4; int need2 = 0; if (num[2] % 4 == 1) need2 = 5; else if (num[2] % 4 == 2) need2 = 3; else if (num[2] % 4 == 3) need2 = 1; int temp_need2 = need2; need2 += num[3] * 5; int need1, tneed2; if (need2 < num[1]) { res += (num[1] - need2+8) / 9; tneed2 = (num[1]-need2)% 9; if (num[2]%4 != 0) { if (tneed2 == 0) need1 = 11 * num[4] + 36 - temp_need2 * 4 - num[2] % 4 * 9; else need1 = 11 * num[4] +36 - temp_need2 * 4 - num[2] % 4 * 9 + 36 - tneed2 * 4; } else { if (tneed2 == 0) need1 = 11 * num[4] ; else need1 = 11* num[4] + 36 - tneed2 * 4; } } else { if (num[2]%4 != 0) need1 = 11 * num[4] + 20* num[3] + 36 - num[2] % 4 * 9 - num[1] * 4; else need1 = 11 * num[4] + 20* num[3] - num[1] * 4; } if (need1<num[0]) { res += (num[0] - need1 + 35) / 36; } cout << res << endl; } return 0; }

    1017:装箱问题

    查看提交统计提示提问 总时间限制: 1000ms 内存限制: 65536kB 描述 一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为1*1, 2*2, 3*3, 4*4, 5*5, 6*6。这些产品通常使用一个 6*6*h 的长方体包裹包装然后邮寄给客户。因为邮费很贵,所以工厂要想方设法的减小每个订单运送时的包裹数量。他们很需要有一个好的程序帮他们解决这个问题从而节省费用。现在这个程序由你来设计。 输入 输入文件包括几行,每一行代表一个订单。每个订单里的一行包括六个整数,中间用空格隔开,分别为1*1至6*6这六种产品的数量。输入文件将以6个0组成的一行结尾。 输出 除了输入的最后一行6个0以外,输入文件里每一行对应着输出文件的一行,每一行输出一个整数代表对应的订单所需的最小包裹数。 样例输入 四个大字:认真读题

    转载请注明原文地址: https://ju.6miu.com/read-35487.html

    最新回复(0)