HDU2192: MagicBuilding

Source: Internet
Author: User

Problem Description
As 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 into 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.
 


Input
The 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.
 


Output
For each test case, output a number perline, meaning the minimal number of the MagicBuilding that can be made.
 


Sample Input
2
1
2
5
1 2 2 3 3


Sample Output
1
2

Directly output the maximum number of times

[Cpp] # include <stdio. h>
# Include <algorithm>
Using namespace std;
 
Int a [1000000];
 
Int main ()
{
Int n;
Scanf ("% d", & n );
While (n --)
{
Int m, I;
Scanf ("% d", & m );
For (I = 0; I <m; I ++)
Scanf ("% d", & a [I]);
Sort (a, a + m );
Int l = 1, tem = a [0], max = 1;
For (I = 1; I <m; I ++)
{
If (a [I] = tem)
{
L ++;
}
Else
{
Tem = a [I];
L = 1;
}
If (l> max)
Max = l;
}
Printf ("% d \ n", max );
}
 
Return 0;
}

# Include <stdio. h>
# Include <algorithm>
Using namespace std;

Int a [1000000];

Int main ()
{
Int n;
Scanf ("% d", & n );
While (n --)
{
Int m, I;
Scanf ("% d", & m );
For (I = 0; I <m; I ++)
Scanf ("% d", & a [I]);
Sort (a, a + m );
Int l = 1, tem = a [0], max = 1;
For (I = 1; I <m; I ++)
{
If (a [I] = tem)
{
L ++;
}
Else
{
Tem = a [I];
L = 1;
}
If (l> max)
Max = l;
}
Printf ("% d \ n", max );
}

Return 0;
}


 

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.