HDU 5463
题意:一个盒子有36个格子、每个格子可以装64个物品,搬运一个箱子是一次搬运,问最少到搬运次数
思路:直接求总需要多少个格子,然后去求盒子,这里求盒子呢有个小技巧,就是用ceil函数
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int num[];
int main()
{
int t;cin >> t;
while(t--)
{
int n;cin >> n;
memset(num,,sizeof(num)); //每次需要清零 、
int mmax;
mmax=;
for(int i=;i<n;++i){
int a,b;cin >> a >> b;
num[a]+=b; //统计每一个种类的总数、
if(a>mmax) mmax=a; //记录最大的种类数字 、
}
int tot=;
for(int i=;i<=mmax;++i){
if(num[i]!=)
tot+=ceil(1.0*num[i]/);
}
cout << ceil(1.0*tot/) << endl;
}
}
ceil函数包含在头文件“cmath”,ceil(),括号里面要是实数,求是的大于等于这个实数的最大整数,很多想这类种类问题都可以用ceil函数来求解
HDU 5463的更多相关文章
- hdu 5463 Clarke and minecraft
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5463 Clarke and minecraft Time Limit: 2000/1000 MS (J ...
- hdu 5463 Clarke and minecraft(贪心)
Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned i ...
- hdu 5463(水水)
Sample Input 2 3 2 33 3 33 2 33 10 5 467 6 378 7 309 8 499 5 320 3 480 2 444 8 391 5 333 100 499 S ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- Ubuntu的网络共享
实际场景 公司项目中遇到一个场景:Ubuntu的主机上装了个4G卡(USB模式),需要将这个4G网共享给一个AP,使得所有连接AP的移动设备都可以通过4G上外网 方法很简单: 1. 将4G网口之外的另 ...
- 在redhat 6.6上安装Docker
安装环境 支持Docker的RHEL版本 Red Hat Enterprise Linux 7 (64-bit) Red Hat Enterprise Linux 6.5 (64-bit) 或更高版本 ...
- oracle 索引监控
索引对于在大量数据里检索出少量数据库的查询操作来说是高效的,可是对于DML操作来说.却是负面的:①其对于insert 操作的反面影响最大.该表的索引越多,更新的索引越多,insert 操 ...
- Docker.[3].镜像操作.
Docker.[3].镜像操作. 熟悉基础指令: 查看本地镜像 docker images 查看本地镜像 docker image list (和上面显示的结果一样.) 删除本地镜像 docker r ...
- Vue项目中出现Loading chunk {n} failed问题的解决方法
最近有个Vue项目中会偶尔出现Loading chunk {n} failed的报错,报错来自于webpack进行code spilt之后某些bundle文件lazy loading失败.但是这个问题 ...
- Python datetime对象的方法
- Amazon Redshift数据迁移到MaxCompute
Amazon Redshift数据迁移到MaxCompute Amazon Redshift 中的数据迁移到MaxCompute中经常需要先卸载到S3中,再到阿里云对象存储OSS中,大数据计算服务Ma ...
- JavaScript--对象继承(组合继承)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 如何用SPSS分析学业情绪量表数据
如何用SPSS分析学业情绪量表数据 1.数据检验.由于问卷.量表的题目是主观判断和选择,因而难免有些人不认真填,所以,筛选出有效.高质量的数据非常关键.通常需要作如下检查:(1)是否有人回答互相矛盾, ...
- day39 10-Spring的AOP:基于AspectJ的切点定义
切点是我们真正应用在哪些方法上,增强的那些方法上,就是add().update()和find().delete()是没用的.没用的话就是这三个方法.为什么要定义一个切点呢? 所以可以直接在切面中定义一 ...