POJ 1017(贪心)

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;

int main()
{
    int value[7];
    int key[4] = { 0, 5, 3, 1 };
    while (1)
    {
        int temp=0;
        for (int i = 1; i<7; i++)
        {
            cin >> value[i];
            temp+= value[i];
        }
        if (temp == 0)
        {
            return 0;
        }
        int sum = 0;
        sum = value[6] + value[5] + value[4] + (value[3] + 3) / 4;
        int a2 = value[4] * 5 + key[value[3] % 4];
        if (value[2]>a2)
            sum += (value[2] - a2 + 8) / 9;
        int a1 = sum * 36 - value[6] * 36 - value[5] * 25 - value[4] * 16 - value[3] * 9 - value[2] * 4;
        if (value[1]>a1)
            sum += (value[1] - a1 + 35) / 36;
        cout << sum << endl;
    }
    return 0;
}

你可能感兴趣的:(ACM_POJ,贪心)