problem Description
Clarke isa patient with multiple personality disorder. One day, Clarke turned to a game player of Minecraft. on this day, ClarkeSetUp local network and chose Create mode forSharing his achievements with others. Unfortunately, a naughty kid came his game. He placed a few creepersinchClarke's castle! When Clarke returned he castle without create mode, Creepers suddenly blew (what a amazing scene!). Then Clarke'S Castleinchruins, 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 theminchThe chests. Clarke clearly remembered the type and number of each item (each item is made of only one type material). Now Clarke want to know how many times he has to transport at least. Note:materials which have same type can be stacked, a grid can store -Materials of same type at the 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≤): The first line contains a number n, The number of items. Then n lines follow, each line contains the integer a A, a (1≤a,b≤ this
Output
For each testcase, print a number, the number of times that Clarke need to transport at least.
Sample Input
1 2 3 1 2
Sample Output
1 2
Hint:
2 2 1 3. So we only need to transport once;
Source
bestcoder Round #56 (Div.2)
Attach Chinese title:
Clark is a schizophrenic patient. One day, Clark split into a student, doing a problem. Suddenly a difficult problem to the Clark, the problem is this: give you the number of N, asked to choose some number (can not choose), add them up, so that it is just a multiple of P (0 is also a multiple of p), the number of solutions. Clark is easy to find when n is very small. However, when N was a big time, Clark had no choice, so he came to you.
Attach the official puzzle:
Greedy, the same material piled into a lattice, and then each time is filled with 36 lattice, filled with the transport can be. Note the upper bound operation.
1 #pragmaComment (linker, "/stack:1024000000,1024000000")2#include <iostream>3#include <cstdio>4#include <cstring>5#include <cmath>6#include <math.h>7#include <algorithm>8#include <queue>9#include <Set>Ten#include <bitset> One#include <map> A#include <vector> -#include <stdlib.h> -#include <stack> the using namespacestd; - intdirx[]={0,0,-1,1}; - intdiry[]={-1,1,0,0}; - #definePI ACOs (-1.0) + #defineMax (a) (a) > (b)? (a): (b) - #defineMin (a) (a) < (b)? (a): (b) + #definell Long Long A #defineEPS 1e-10 at #defineMOD 1000000007 - #defineN 1000000 - #defineINF 1e12 - intN; -map<int,int>MP; - in intMain () - { to intT; +scanf"%d",&t); - while(t--){ the mp.clear (); *scanf"%d",&n); $ for(intI=0; i<n;i++){Panax Notoginseng intx, y; -scanf"%d%d",&x,&y); themp[x]+=y; + } A the intans=0; + intg=0; - for(intI=1; i<=506; i++){ $ if(Mp[i]) { $g+=mp[i]/ -; - if(mp[i]% -!=0){ -g++; the } - }Wuyi } the -ans=ans+g/ $; Wu - if(g% $!=0){ Aboutans++; $ } -printf"%d\n", ans); - - } A return 0; +}
View Code
Hdu 5463 Clarke and Minecraft (greedy)