YTU.3155: 贪心之Packets
来源:互联网 发布:日系化妆品 知乎 编辑:程序博客网 时间:2024/06/05 05:31
3155: 贪心之Packets
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 8 Solved: 7
[Submit][Status][Web Board]
Description
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.
Input
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.
Output
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.
Sample Input
0 0 4 0 0 17 5 1 0 0 00 0 0 0 0 0
Sample Output
21
AC代码:
#include <stdio.h>int main(){ int N, a, b, c, d, e, f, y, x; int u[4]= {0, 5, 3, 1}; while(1) { scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f); if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0 && f == 0) break; N = f + e + d + (c + 3) / 4; y = 5 * d + u[c % 4]; if(b > y) N += (b - y + 8 ) / 9; x = 36 * N - 36 * f - 25 * e - 16 * d - 9 * c - 4 * b; if(a > x) N += ( a - x + 35 ) / 36; printf("%d\n", N); } return 0;}题目详解:
http://blog.csdn.net/dongfengkuayue/article/details/6461374
- YTU.3155: 贪心之Packets
- 贪心算法之Packets
- Packets-贪心
- 贪心&Packets
- poj 1017 Packets【贪心】
- POJ 1017 Packets(贪心)
- poj 1017 Packets(贪心)
- 1017 Packets 贪心
- poj 1017 Packets ( 贪心 )
- POJ 1017Packets(贪心)
- [贪心]uva311 Packets
- uva311 - Packets(贪心)
- POJ1017 Packets 【贪心】
- 贪心算法--Packets
- Packets (poj 1017 贪心)
- 贪心- poj1017 Packets
- [贪心]poj1017 packets
- poj 1017 Packets 贪心
- Mysql分别在windows和linux下导入导出sql文件
- No outbound converter found for XXX
- python 部署pythonweb开发的几种方式
- 语音测试基础以及demo解读
- Linux 搭建 ftp 环境
- YTU.3155: 贪心之Packets
- Git常用命令
- 记录一下怎么使用pycaffe调用已有的网络模型识别人脸(物体)
- intelliJ IDEA 2017.1.3 创建maven web项目
- CSDN Markdown 博客范文代码
- 深度学习高手该怎样炼成?这位拿下阿里天池大赛冠军的中科院博士为你规划了一份专业成长路径
- AR# 54242: Install
- 重磅 阿里云成为CNCF白金会员
- The following untracked working tree files would be overwritten by merge(reset 无效时)