次数nullhdu2192(MagicBuilding 贪心)

文章结束给大家来个程序员笑话:[M]

    

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 obviously.

    

 

    

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

    标题意思是:求出最少要建的栋数(一栋可以有很多房);

    思路:算出最多涌现的次数房的个数.

#include<stdio.h>
int main()
{
    int t,n,a[10005]e,i,j,sum;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        
        for(i=0;i<n;i++)
        scanf("%d",&a[i]);
        sum=0;
        for(i=0;i<n;i++)
        {
            e=1;
            for(j=i+1;j<n;j++)
            if(a[i]==a[j])
            {
               e++;
            }
            if(e>sum)//这房涌现的次数
            sum=e;
           
        }
        printf("%d\n",sum);
    }
}

    
 

文章结束给大家分享下程序员的一些笑话语录: 问路
有一个驾驶热气球的人发现他迷路了。他降低了飞行的高度,并认出了地面 上的一个人。他继续下降高度并对着那个人大叫,“打扰一下,你能告诉我我 在哪吗?”
下面那个人说:“是的。你在热气球里啊,盘旋在 30 英尺的空中”。
热气球上的人说:“你一定是在 IT 部门做技术工作”。
“没错”,地面上的人说到,“你是怎么知道的?”
“呵呵”,热气球上的人说,“你告诉我的每件事在技术上都是对的,但对都没 有用”。
地面上的人说,“你一定是管理层的人”。
“没错”,热气球上的人说,“可是你是怎么知道的?”
“呵呵”,地面上的那人说到,“你不知道你在哪里,你也不知道你要去哪,你 总希望我能帮你。你现在和我们刚见面时还在原来那个地方,但现在却是我 错了”。

--------------------------------- 原创文章 By 次数和null ---------------------------------

原文地址:https://www.cnblogs.com/jiangu66/p/3095448.html