HDU5463 Clarke and Minecraft

Source: Internet
Author: User

Problem-solving ideas: This problem just beginning, feel good cumbersome, good confusion, clear ideas, found very simple.

See Code Analysis for details.

1#include <cstdio>2#include <cstring>3#include <algorithm>4 using namespacestd;5 Const intMAXN =505;6 intHASH1[MAXN];//the total number of tokens corresponding to the type. 7 intMain ()8 {9     intT, N, a, B, sum, CNT;Tenscanf"%d", &t); One      while(t--) A     { -scanf"%d", &n); -memset (HASH1,0,sizeof(HASH1)); the          while(n--) -         { -scanf"%d%d", &a, &b); -Hash1[a] + = b;//hash1 Tag corresponding type total number of occurrences +         } -sum = CNT =0; +          for(inti =0; I <=505; i++)//because both A and B have a value range of A         { at             if(Hash1[i])//If there has been -             { -Sum + = hash1[i]/ -;//sum records how many squares to put in total -                 if(hash1[i]% -) sum + +;//if it is not divisible, put one more lattice -CNT + = sum/ $, Sum%= $;//The total number of CNT records to be shipped -             } in         } -         if(sum) CNT + +;//if sum is not divisible, it will be shipped one more time toprintf"%d\n", CNT); +     } -     return 0; the}
View Code

HDU5463 Clarke and Minecraft

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.