重复数
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;
}