UVa 311 - Packets
题目大意:有1X1,2X2 ... 5X5,6X6六种类型的物品,把他们装进6X6的盒子里,求使用的最少盒子数。
贪心吧,其实一看就知道思路了,算是常识吧,装物品时通常都是先装大的,再在其余空间放小的。一点一点敲代码就好了。
#include <cstdio> int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int a[];
while (scanf("%d%d%d%d%d%d", &a[], &a[], &a[], &a[], &a[], &a[]) != EOF)
{
if (!a[] && !a[] && !a[] && !a[] && !a[] && !a[]) break;
int ans = ;
if (a[] > )
{
ans += a[];
}
if (a[] > )
{
ans += a[];
a[] -= a[] * ;
}
if (a[] > )
{
ans += a[];
a[] -= a[] * ;
if (a[] < )
{
a[] -= - * a[];
a[] = ;
}
}
if (a[] > )
{
ans += (a[]+) / ;
int t = a[] % ;
switch(t)
{
case :
a[] -= ;
a[] -= ;
break;
case :
a[] -= ;
a[] -= ;
break;
case :
a[] -= ;
a[] -= ;
break;
}
}
if (a[] > )
{
ans += (a[]+) / ;
int t = a[] % * ;
a[] -= - t;
}
if (a[] > ) ans += (a[]+) / ;
printf("%d\n", ans);
}
return ;
}
代码可以再精简,不过精简之后思路就不如这个直接了,其实是我想偷懒啦,哈哈
UVa 311 - Packets的更多相关文章
- UVA 311 Packets 贪心+模拟
题意:有6种箱子,1x1 2x2 3x3 4x4 5x5 6x6,已知每种箱子的数量,要用6x6的箱子把全部箱子都装进去,问需要几个. 一开始以为能箱子套箱子,原来不是... 装箱规则:可以把箱子都看 ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- uva311 - Packets(贪心)
题目:311 - Packets 题目大意:给出1*1, 2*2,3 *3, 4*4, 5*5, 6*6的箱子的个数,如今有若干个6*6的箱子,问最少用多少个箱子能够将给定的箱子都装进去. 解题思路: ...
- 利用iptables实现基于端口的网络流量统计
如何统计某个应用的网络流量(包括网络流入量和网络流出量)问题,可以转换成如何基于端口号进行网络流量统计的问题.大部分网络应用程序都是传输层及以上的协议,因此基于端口号(tcp, udp)统计网络流量基 ...
- 【习题 3-11 UVA - 1588】Kickdown
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟一下就好 一位一位地往右移动. [代码] #include <bits/stdc++.h> using namesp ...
- UVa 10791 - Minimum Sum LCM(唯一分解定理)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVa 465 Overflow——WA
上次那个大数开方的高精度的题,UVa113 Power of Cryptography,直接两个double变量,然后pow(x, 1 / n)就A过去了. 怎么感觉UVa上高精度的题测试数据不给力啊 ...
- Fast Matrix Operations(UVA)11992
UVA 11992 - Fast Matrix Operations 给定一个r*c(r<=20,r*c<=1e6)的矩阵,其元素都是0,现在对其子矩阵进行操作. 1 x1 y1 x2 y ...
- 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 ...
随机推荐
- $.ajax和$.post的区别(前者根据key-value/后者根据形参)
post不需要给key-value形式: $("#btn").click(function(){ var url=basePath+"/emp/login"; ...
- 关于Context []startup failed due to previous errors有效解决方式
http://blog.csdn.net/mcpang/article/details/5468386
- HDU 1934 树状数组 也可以用线段树
http://acm.hdu.edu.cn/showproblem.php?pid=1394 或者是我自己挂的专题http://acm.hust.edu.cn/vjudge/contest/view. ...
- Win下安装Cygwin中的SSH服务
windows和linux各有其优越性,可以安装在同一台电脑上,但切换要重启.同时拥有两台电脑,一台装win,一台装linux,自然非常好,但具备此条件的不多.本文介绍cygwin,它可以让你在win ...
- Textbox服务器控件
<body> <form id="form1" runat="server"> <div> 姓名:<asp:TextB ...
- js document
<html><head lang="en"> <meta charset="UTF-8"> <title>< ...
- PAT (Advanced Level) 1068. Find More Coins (30)
01背包路径输出. 保证字典序最小:从大到小做背包. #include<cstdio> #include<cstring> #include<cmath> #inc ...
- PHP聊天室开源系统workerman-chat
PHP聊天室开源系统workerman-chat (2015-01-23 09:07:50) 转载▼ http://www.workerman.net/ http://www.workerman.ne ...
- 在Ubuntu 14.04 64bit上安装StarUML 2.5版本
1,在“http://staruml.io/”下载: 2,sudo dpkg -i StarUML-v2.5.0-64-bit.deb安装. 3,注册 .在help中输入.name:maxiongyi ...
- WordPress主题制作第二天
<?php if(have_posts()): while(have_posts()): the_post(); <!-- the_title(); the_permalink(); th ...