POJ1017 贪心

#include <iostream>
using namespace std;
typedef long long ll;
ll num[10], ans = 0LL;
void input()
{
    for (int i = 1; i <= 6; i++)
    {
        scanf("%lld", &num[i]);
        if (num[i] < 0LL)
        {
            num[i] = 0LL;
        }
    }
}
void solveSix()
{
    ans += num[6];
}
void solveFive()
{
    ans += num[5];
    num[1] -= (num[5] * 11LL);
}
void solveFour()
{
    ans += num[4];
    num[2] -= (num[4] * 5LL);
}
void solveThree()
{
    ans += ((num[3] + 3LL) / 4LL);
    num[3] = num[3] % 4LL;
    switch (num[3])
    {
    case 0LL:
        break;
    case 1LL:
        num[2] -= (5LL);
        num[1] -= (7LL);
        break;
    case 2LL:
        num[2] -= (3LL);
        num[1] -= (6LL);
        break;
    case 3LL:
        num[2] -= (1);
        num[1] -= (5LL);
        break;
    default:
        break;
    }
}
void solveTwo()
{
    if (num[2] < 0LL)
    {
        num[1] += (num[2] * 4LL);
    }
    else if (num[2] > 0)
    {
        ans += ((num[2] + 8LL) / 9LL);
        num[2] = num[2] % 9LL;
        switch (num[2])
        {
        case 0:
            break;
        case 1:
            num[1] -= 32LL;
            break;
        case 2:
            num[1] -= 28LL;
            break;
        case 3:
            num[1] -= 24LL;
            break;
        case 4:
            num[1] -= 20LL;
            break;
        case 5:
            num[1] -= 16LL;
            break;
        case 6:
            num[1] -= 12LL;
            break;
        case 7:
            num[1] -= 8LL;
            break;
        case 8:
            num[1] -= 4LL;
            break;
        default:
            break;
        }
    }
}
void solveOne()
{
    if (num[1] > 0LL)
    {
        ans += ((num[1] + 35LL) / 36LL);
    }
}
int main()
{
    while (true)
    {
        input();
        if (num[1] == 0LL && num[2] == 0LL && num[3] == 0LL && num[4] == 0LL && num[5] == 0LL && num[6] == 0LL)
        {
            break;
        }
        ans = 0LL;
        solveSix();
        solveFive();
        solveFour();
        solveThree();
        solveTwo();
        solveOne();
        printf("%lld\n", ans);
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值