UVA 311 Packets

 

贪心,用到了许多小技巧,向下取整等。

CODE:

 

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using  namespace std;

int u[ 4] = { 0531};    // 以三的剩余个数进行分类 

int main()
{
     int one, two, three, four, five, six;
     while(scanf( " %d%d%d%d%d%d ", &one, &two, &three, &four, &five, &six))
    {
         int tot =  0;
         if(one ==  0 && two ==  0 && three ==  0 && four ==  0 && five ==  0 && six ==  0break;
        tot = six + five + four + (three+ 3)/ 4;     // 向下取整,计算3x3需要的空间。 
         int y = four* 5 + u[three% 4];    // 计算可以容纳2x2箱子的个数 
         if(two > y) tot += (two-y+ 8)/ 9;            // 向下取整
         int dif =  36*tot -  36*six -  25*five -  16*four -  9*three -  4*two; // 剩余可以容纳1x1箱子的个数 
         if(one > dif) tot += (one-dif+ 35)/ 36// 向下取整 
        printf( " %d\n ", tot);
    }
     return  0;
}

 

转载于:https://www.cnblogs.com/g0feng/archive/2012/10/15/2724925.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值