packets  

时间限制(普通/Java):1000MS/10000MS     运行内存限制:65536KByte
总提交: 27            测试通过: 14

描述

A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parcels of the same height h as the products have and of the size 6*6. Because of the expenses it is the interest of the factory as well as of the customer to minimize the number of parcels necessary to deliver the ordered products from the factory to the customer. A good program solving the problem of finding the minimal number of parcels necessary to deliver the given products according to an order would save a lot of money. You are asked to make such a program.

输入

The input file consists of several lines specifying orders. Each line specifies one order. Orders are described by six integers separated by one space representing successively the number of packets of individual size from the smallest size 1*1 to the biggest size 6*6. The end of the input file is indicated by the line containing six zeros.

输出

The output file contains one line for each line in the input file. This line contains the minimal number of parcels into which the order from the corresponding line of the input file can be packed. There is no line in the output file corresponding to the last ``null'' line of the input file.

样例输入

0 0 4 0 0 1
7 5 1 0 0 0
0 0 0 0 0 0

样例输出

2
1

题目上传者

crq

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm> using namespace std;
int v[10];
int ava[10];
int cnt = 0; void work() {
cnt = 0;//init
int res;//剩余的
cnt += v[6];//v[6] == 0;
if(v[5]) { //v[5] == 0;
cnt += v[5];
ava[1] += v[5]*11;//ava[1] += 11;!!!
}
if(v[4]) {
cnt += v[4];
ava[2] += v[4] * 5;
}
if(v[3]) {
int tag = true;
cnt += v[3]/4 ;//v[3] < 4; 3*3*4 == 36;
res = v[3]%4; //占用了几个. if(res==0) tag = false;
else cnt++; if(res==1 && tag) {//占用一个3*3
ava[2] += 5;
ava[1] += 7;
tag = false;
}
if(res==2 && tag){//two 3*3
ava[2] += 3;
ava[1] += 6;
tag = false;
}
if(res==3 && tag) {
ava[2] += 1;
ava[1] += 5;
tag = false;
}
}
if(v[2]) {
if(ava[2] >= v[2]) {
ava[1] += (ava[2]-v[2]) * 4;
}
else {
v[2] -= ava[2];
cnt += v[2]/9;//2*2*9 = 36
res = v[2]%9;
if(res != 0) cnt++;
ava[1] += (9-res) * 4;
}
}
if(v[1]) {
if(ava[1]>=v[1]) {
return;
}
else {
v[1] -= ava[1];
cnt += v[1]/36;
res = v[1]%36;
if(res) cnt++;
}
}
return;
} int main()
{
memset(ava, 0, sizeof(ava));
memset(v, 0, sizeof(v));
while(scanf("%d%d%d%d%d%d", &v[1], &v[2], &v[3], &v[4], &v[5], &v[6])==6) {
if(v[0]==v[1] && v[1]==v[2]&&v[2]==v[3]&&v[3]==v[4]&&v[4]==v[5]&&
v[5]==v[6]&&v[6]==0) break;
work();
printf("%d\n", cnt);
memset(ava, 0, sizeof(ava));
memset(v, 0, sizeof(v));
}
return 0;
}

packets的更多相关文章

  1. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    今天项目中报了如下错误 The last packet sent successfully to the server was 0 milliseconds ago. The driver has n ...

  2. RUDP之二 —— Sending and Receiving Packets

    原文链接 原文:http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/ Send ...

  3. Packets(模拟 POJ1017)

    Packets Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 47750 Accepted: 16182 Description ...

  4. PCI Express(三) - A story of packets, stack and network

    原文出处:http://www.fpga4fun.com/PCI-Express3.html Packetized transactions PCI express is a serial bus. ...

  5. MySQL报错:Packets larger than max_allowed_packet are not allowed 的解决方案

    在导大容量数据特别是CLOB数据时,可能会出现异常:“Packets larger than max_allowed_packet are not allowed”. 这是由于MySQL数据库有一个系 ...

  6. poj 1017 Packets 裸贪心

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 43189   Accepted: 14550 Descrip ...

  7. What is martian source / martian packets

    Martian source / Martian packets In Linux, by default, packets are considered individually for routi ...

  8. openstack 控制节点大流量对外发包,nf_conntrack,table full droping packets

    某些人很MJJ,挂了N多代理来疯狂采集,把服务器带宽都耗尽了,没办法只好封掉一些! 目前发现的问题openStack kilo for ubuntu manuual运行一段时间后 云平台的控制节点p5 ...

  9. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. (关于jdbc)

    The last packet sent successfully to the server was milliseconds ago. The driver has not received an ...

随机推荐

  1. FusionChart学习笔记(部分)

    目录 第一阶段    1 一.创建第一个FusionChart    1 (1)导入js文件    1 (2)定义Div Id    1 (3)定义xml格式的数据文件    1 (4)编写js代码  ...

  2. B/S 獲取客戶端Mac地址

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx. ...

  3. Android Studio使用教程图文详解

    谷歌表示Android Studio 1.0 能让开发者“更快更有生产力”,并认为它可以代替 Eclipse,同时为Eclipse 用户提供迁移步骤.代码自动提示.运行响应速度.都比Eclipse来的 ...

  4. Asp.net 主题 【2】

    通常我们经常看到网页,一些软件提供换肤功能,各种主题间切换.ASP.NET 2.0 中可以用Theme和skin以及CSS轻松实现这个功能. 首先简单介绍一下三种技术:主题(Theme)技术,面板(s ...

  5. Linq 实现普通sql中 where in 的功能

    user.ProjectIds 的值是使用逗号分隔的 例如:1,2,3 projectList = (from a in projectList where (user.ProjectIds.Spli ...

  6. html5 的百度地图连接

    在一些网站上,我们经常会看到一些地址会有一个图标的形式展现,当你点击的时候就会加载一个你点击区域的地图出来,很神奇的一个功能,在之前是没有这样功能的,都是直接写上地址,你要去的话自己找去吧,现在有了这 ...

  7. 2D简单图形相关算法罗列

    因为平常在Qt开发过程中经常会与一些简单的2D几何图形打交道,因此学习和掌握一些基本的2D几何计算还是很有必要的,在这里罗列一些常用的基本情况,之后会适时补充. [1] 两点之间距离,根据两个点的差值 ...

  8. JVM内存管理及垃圾回收

    一.JVM内存的构 Java虚拟机会将内存分为几个不同的管理区,这些区域各自有各自的用途,根据不同的特点,承担不同的任务以及在垃圾回收时运用不同的算法.总体分为下面几个部分: 程序计数器(Progra ...

  9. Spring+SpringMVC+Mybatis+MAVEN+Eclipse+项目完整环境搭建

    1.新建一个Maven项目,创建父项目. 2.创建子项目模块 3.创建javaWeb项目 4.创建后的项目目录结构 5.Maven文件配置 parent父项目pom.xml文件配置 <?xml ...

  10. Jquery练手之-贪吃蛇

    记得以前刚出来工作的时候,什么都不懂.老板让用Jquery写一个功能,我不会写,然后跟老板说,我就是个.net程序员,为什么要写Jquery...后面我们老大给我写了!现在我才知道net程序员要会多少 ...