EOJ-----重复数

重复数

Time limit per test: 1.0 seconds

Time limit all tests: 1.0 seconds

Memory limit: 256 megabytes

有n个(1≤n≤1000) int类型的整数,统计其中重复出现次数最多的数。

Input

第 1 行:整数T(1≤T≤10)为问题数。

第 2 行:整数n为第一个问题中整数的个数。

第 3 行:第一个问题中的n个整数,每两个数字之间用一个空格分开。

接下来每个问题占两行,格式与第一个问题相同。

Output

对于每个问题,输出一行问题的编号(0开始编号,格式:case #0: 等);然后在一行中输出1个整数,表示重复出现最多的整数出现的次数。

Examples

Input
3
4
8 1 2 1 
3
-1 -1 10000
13
1 1 1 6 2 3 6 0 4 9 6 5 8
Output
case #0:
2
case #1:
2
case #2:
3

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int main()
{
    int t,n,a,cas=0;
    scanf("%d",&t);
    while(t--)
    {
        set<int> S;
        map<int,int>Q;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a);
            S.insert(a);
            Q[a]++;
        }
        int maxx=0;
        set<int>::iterator it;
        for(it=S.begin();it!=S.end();it++)
        {
            if(Q[*it]>maxx)
                maxx=Q[*it];
        }
        printf("case #%d:\n%d\n",cas++,maxx);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值