Bestcoder Round #56/hdu5463 Clarke and Minecraft water problem

Source: Internet
Author: User

Clarke and Minecraft problem description
Clark is a schizophrenic patient. One day, Clark split into a game player and played Minecraft. Gradually, Clark built a castle.  one day, Clark, in order to let more people share their results, open a local area network, and choose Creative mode. Unfortunately, there was a bear kid in Clark's game this day, and he put a lot of creepers in Clark's Castle! When Clark, who had just gone outside to play the strange back and open the survival mode, returned to the castle for a moment, the creepers suddenly blew themselves ... (self-image) Clark's Castle became a ruin, with cobblestone, planks, bricks and other building materials scattered over the ground.  helpless Clark had to pick up the ruins, ready to rebuild. After Clark had built enough boxes, he wanted to carry the scattered material all the way to the box. Clark clearly remembers how much material he had used and what kind of material he had built. Now Clark wants to know how many times Clark needs to move at least to get all the material in the box.  Note: The material can be stacked, and a lattice can hold up to 64 identical materials. Materials for different items can be transported to the box at once. Minecraft has a total of 4*9=36 in the backpack bar.  
Enter a description
First line an integerT (1 \le T \le 10)T(1≤T≤10), which represents the number of groups of data. The first row of each set of data is a positive integerN (1 \le n \le 100)N(1≤N≤100), indicating the number of things. NextNn rows, each row has two positive integersA, B (1 \le A, b \le 500)a , b (1≤ a,b≤ 500aa represents the type of material for this thing, b< Span class= "katex-html" >< Span class= "Mord Mathit" >b represents the quantity of this material.  
Output description
For each set of data, output an integer that represents the minimum number of times that Clark has been transported.  
Input sample
232 333 332 33105 4676 3787 3098 4995 3203 4802 4448 3915 333100 499
Output sample
12
Hint
The first example, for 2nd items we use 2 square to put, 3rd items alone, a total of 3 compartments, transport 1 times.


Water
//1085422276#include <iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<queue>#include<cmath>#include<map>#include<bitset>#include<Set>#include<vector>#include<stack>using namespacestd; typedefLong Longll;#defineMem (a) memset (A,0,sizeof (a))#defineMeminf (a) memset (A,127,sizeof (a));#defineMemfy (a) memset (A,-1,sizeof (a))#defineTS printf ("111111\n");#definefor (I,A,B) for (int i=a;i<=b;i++)#defineForj (I,A,B) for (int i=a;i>=b;i--)#defineREAD (A, b) scanf ("%d%d", &a,&b)#defineMoD 530600414#defineMAXN 506inline ll read () {ll x=0, f=1; CharCh=GetChar ();  while(ch<'0'|| Ch>'9')    {        if(ch=='-') f=-1; CH=GetChar (); }     while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; CH=GetChar (); }    returnx*F;}//****************************************intG[maxn],n;intMain () {intt=read ();  while(t--) {scanf ("%d",&N);        MEM (G); intb; For (I,1, N) {scanf ("%d%d",&a,&b); G[a]+=b; }        intans=0;  for(intI=1; i<= -; i++)        {            if(G[i]) {ans+=g[i]/ -; G[i]=g[i]% -; if(G[i]) ans++; }        }        intsum=0; if(ans% $) Sum+=1; Sum+=ans/ $; cout<<sum<<Endl; }    return 0;}
Code

Bestcoder Round #56/hdu5463 Clarke and Minecraft water problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.