您的位置:首页 > 其它

Clarke and minecraft hdoj 5463 (数学题)

2015-09-23 22:26 393 查看

Clarke and minecraft

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 457    Accepted Submission(s): 234


[align=left]Problem Description[/align]
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.

[align=left]Input[/align]
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.

[align=left]Output[/align]
For each testcase, print a number, the number of times that Clarke need to transport at least.

[align=left]Sample Input[/align]

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

[align=left]Sample Output[/align]

1
2

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; //题意:有一个背包,有36个格子,一个格子可以装64个物品,同一个格子不能装不同的物品,但不同的格子可以装不同的物品。问克拉克将这些物品全移走,一共要跑几趟。 
#include<stdio.h>
#include<string.h>
#include<math.h>
int a[600];
int main()
{
int t;
int n,i,j;
int x,y;
scanf("%d",&t);
while(t--)
{
memset(a,0,sizeof(a));
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d",&x,&y);
a[x]+=y;
}
int k=0;
for(i=0;i<600;i++)
{
if(a[i])
{
k+=(int)ceil(a[i]*1.0/64);
}
}
printf("%d\n",(int)ceil(k*1.0/36));
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: