这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1029
又是水题,直接用map即可。
#include
#include
using namespace std;
int N;
int main()
{
//freopen("input.txt", "r", stdin);
int num;
while(cin >> N)
{
map wtq;
for(int i=1; i<=N; ++i)
{
cin >> num;
++wtq[num];
}
int cnt = -1, id = 1;
for(map::iterator it=wtq.begin(); it!=wtq.end(); ++it)
{
if(cnt < it->second)
{
cnt = it->second;
id = it->first;
}
}
cout << id << endl;
}
}