程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> HDU 5463Clarke and minecraft

HDU 5463Clarke and minecraft

編輯:C++入門知識

HDU 5463Clarke and minecraft


 

Clarke and minecraft

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 260 Accepted Submission(s): 136



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
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

Sample Output
1
2

 

水題,有一個背包有36個格子 每個格子只能放一種物品,且最多只能疊加64個 問要多少次才能將物品運完

 

 

#include 
#include 
#include 
#include 
#include 
#include
#include 
#include 
#include 
#include 
using namespace std;

int a[505];

void add()
{
    int sum=0,t=0;
    for(int i=1;i<=500;i++)
    {
        if(a[i])
        {
            sum+=a[i]/64;
            if(a[i]%64) sum++;
            while(sum>=36)
                t++,sum-=36;
        }
    }
    if(sum) t++;
    cout<>t;
    while(t--)
    {
        int n;
        cin>>n;
        memset(a,0,sizeof(a));
        for(int i=0;i>s>>t;
            a[s]+=t;
        }
        add();
    }
}


 

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved