博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5463 Clarke and minecraft(贪心)
阅读量:6454 次
发布时间:2019-06-23

本文共 2639 字,大约阅读时间需要 8 分钟。

Problem Description
Clarke is a patient with multiple personality disorder. One day, Clarke turned into a game player of minecraft. On that day, Clarke set up local network and chose create mode for sharing his achievements with others. Unfortunately, a naughty kid came his game. He placed a few creepers in Clarke's castle! When Clarke returned his castle without create mode, creepers suddenly blew(what a amazing scene!). Then Clarke's castle in ruins, the materials scattered over the ground. Clark had no choice but to pick up these ruins, ready to rebuild. After Clarke built some chests(boxes), He had to pick up the material and stored them in the chests. Clarke clearly remembered the type and number of each item(each item was made of only one type material) . Now Clarke want to know how many times he have to transport at least. Note: Materials which has same type can be stacked, a grid can store 64 materials of same type at most. Different types of materials can be transported together. Clarke's bag has 4*9=36 grids.

 

Input
The first line contains a number T(1≤T≤10), the number of test cases. For each test case: The first line contains a number n, the number of items. Then n lines follow, each line contains two integer a,b(1≤a,b≤500), a denotes the type of material of this item, b denotes the number of this material.

 

 

Output
For each testcase, print a number, the number of times that Clarke need to transport at least.

 

 
Sample Input
12 31 2

 

Sample Output
12

 

Hint:
The first sample, we need to use 2 grids to store the materials of type 2 and 1 grid to store the materials of type 3. So we only need to transport once;

 

Source
 

 附上中文题目:

克拉克是一名人格分裂患者。某一天,克拉克分裂成了一个学生,在做题。 突然一道难题难到了克拉克,这道题是这样的:  给你n个数,要求选一些数(可以不选),把它们加起来,使得和恰好是p的倍数(0也是p的倍数),求方案数。  对于n很小的时候,克拉克是能轻易找到的。然而对于n很大的时候,克拉克没有办法了,所以来求助于你。

附上官方题解:

贪心,将同样材料堆到一格里,然后每一次都装满36个格子,装满就运即可。注意取上界操作。

 

1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 using namespace std;16 int dirx[]={ 0,0,-1,1};17 int diry[]={-1,1,0,0};18 #define PI acos(-1.0)19 #define max(a,b) (a) > (b) ? (a) : (b) 20 #define min(a,b) (a) < (b) ? (a) : (b)21 #define ll long long22 #define eps 1e-1023 #define MOD 100000000724 #define N 100000025 #define inf 1e1226 int n;27 map
mp;28 29 int main()30 {31 int t;32 scanf("%d",&t);33 while(t--){34 mp.clear();35 scanf("%d",&n);36 for(int i=0;i
View Code

 

转载地址:http://bqyzo.baihongyu.com/

你可能感兴趣的文章
Redis慢查询,redis-cli,redis-benchmark,info
查看>>
Virtualbox 虚拟机网络不通
查看>>
java概念基础笔记整理
查看>>
CC_UNUSED_PARAM 宏含义的解释
查看>>
leetcode124二叉树最大路径和
查看>>
AngularJS笔记整理 内置指令与自定义指令
查看>>
shell与正则表达式
查看>>
第三篇:白话tornado源码之请求来了
查看>>
表示数值的字符串
查看>>
JQUERY AJAX请求
查看>>
html css 伪样式
查看>>
超级账本Fabric区块链用弹珠游戏Marbles 部署
查看>>
整理Java基础知识--选择与判断
查看>>
Linux查看程序端口占用情况
查看>>
jar包冲突案例分析.md
查看>>
控制圈复杂度的9种重构技术总结
查看>>
当软件项目全部能靠自己搞定了,也能接几万元的软件项目时,未必适合创业...
查看>>
数据分析--数字找朋友
查看>>
推荐好用的开源库或软件
查看>>
18年selenium3+python3+unittest自动化测试教程(下)
查看>>