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

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;
}

 

相关文章:

  • 2021-10-07
  • 2021-12-26
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案