
4 10 20 30 04 5 2 3 4 3 4
1 2
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
const int M=6005;
using namespace std;
int ls[M],gq[M];
int hashh(int k)
{
int t=k;
t=(t%M+M)%M;
if(ls[t]!=0&&gq[t]!=k)
{
t=(t+1)%M;
}
return t;
}
int main()
{
int num,n;
while(cin>>n)
{
memset(ls,0,sizeof(ls));
memset(gq,0,sizeof(gq));
for(int i=0;i<n;i++)
{
scanf("%d",&num);
int p=hashh(num);
gq[p]=num;
ls[p]++;
}
sort(ls,ls+M);
cout<<ls[M-1]<<endl;
}
return 0;
}
#include<iostream>
#include<map>
#include<stdio.h>
using namespace std;
int main()
{
map<int,int>ls;
int n,gq;
while(cin>>n)
{
ls.clear();
int maxx=0;
for(int i=0;i<n;i++)
{
scanf("%d",&gq);
ls[gq]++;
}
for(map<int,int>::iterator it=ls.begin();it!=ls.end();it++)
{
maxx=max(maxx,it->second);
}
cout<<maxx<<endl;
}
return 0;
}#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
int n,M=0;
while(cin>>n)
{
string str;
map<string,int>ls;
for(int i=0;i<n;i++)
{
cin>>str;
ls[str]++;
str.clear();
}
M=0;
for(map<string,int>::iterator it=ls.begin();it!=ls.end();it++)
M=max(M,it->second);
cout<<M<<endl;
}
}
杭电 HDU ACM 1800 Flying to the Mars
原文:http://blog.csdn.net/lsgqjh/article/details/45066963