HDU 2192 magicbuilding (simple sorting by sort)

Source: Internet
Author: User
Magicbuildingtime limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others) Total submission (s): 1314 accepted submission (s): 599

Problem descriptionas the increase of population, the living space for people is becoming smaller and smaller. in magicstar the problem is much worse. dr. mathematica is trying to save land by clustering buildings and then we call the set of buildings magicbuilding. now we can treat the buildings as a square of size D, and the height doesn' t matter. buildings of D1, D2, D3 .... DN can be clustered One magicbuilding if they satisfy Di! = Dj (I! = J ).
Given a series of buildings size, you need to calculate the minimal numbers of magicbuildings that can be made. Note that one building can also be considered as a magicbuilding.
Suppose there are five buildings: 1, 2, 2, 3, 3. we make three magicbuildings (1, 3), (2, 3), (2 ). and we can also make two magicbuilding :( 1, 2, 3), (2, 3 ). there is at least two magicbuildings obviusly.
Inputthe first line of the input is a single number t, indicating the number of test cases.
Each test case starts by N (1 ≤ n ≤ 10 ^ 4) in a line indicating the number of buildings. next n positive numbers (less than 2 ^ 31) will be the size of the buildings.
Outputfor each test case, output a number perline, meaning the minimal number of the magicbuilding that can be made.
Sample Input
212 51 2 2 3 3
 
Sample output
12
 
Authorscnu: How many groups of data are given. when the data is merged, no two values in a group are the same, and the minimum number of data groups is determined? Difficulty: How to Determine the groups of data? Solution: Find the number with the same number. The Code is as follows:
<span style="font-size:14px;">#include<stdio.h>#include<algorithm>using namespace std;int a[10010];int main(){int t,i,n;scanf("%d",&t);while(t--){scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&a[i]);}sort(a,a+n);int sum=1;int Max=1;int m=a[0];for(i=1;i<n;i++){if(a[i]==m){++sum;}else{m=a[i];sum=1;}if(Max<sum)Max=sum;}printf("%d\n",Max);}return 0;}</span>


 

HDU 2192 magicbuilding (simple sorting by sort)

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.