Description

There are N people want to choose the best person. Each person select the best person $a_i$, .John wants to know that who received the most number of votes.      
              

Input

The first line contains a single integer $T(1 \leq T \leq 50)$,indicating the number of test cases.        Each test case begins with an integer $N(1 \leq N \leq 100)$,indicating the number of person.        Next N lines contains an integer $a_i(1 \leq a_i \leq N)$.      
              

Output

For each case, output an integer means who is the best person. If there are multiple answers, print the minimum index.      
              

Sample Input

2 10 1 2 3 4 5 6 7 8 9 10 5 3 3 3 3 3
              

Sample Output

1 3
 
 
 
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int t,n,num,maxn;
int a[];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
maxn=-;
memset(a,,sizeof(a));
for(int i=;i<=n;i++)
{
scanf("%d",&num);
a[num]++;
if(a[num]>maxn)
{
maxn=a[num];
}
}
for(int i=;i<=n;i++)
{
if(a[i]==maxn)
{
printf("%d\n",i);
break;
}
}
}
return ;
}

随机推荐

  1. C# List使用District去重复数据

    class ListDistinctDemo { static void Main(string[] args) { List<Person> personList = new List& ...

  2. Xamarin.Android 入门实例(1)之获取与解析JSON

    1.Main.axml 视图界面 2.视图代码 <?xml version="1.0" encoding="utf-8"?> <LinearL ...

  3. iOS开展-clang: error: unknown argument: &#39;-websockets&#39;解决方案

    问题: 昨天莫名其妙Xcode自己主动升级,那么今天之前执行project什么时候,不知怎的,他们都获得了. 错误内容: clang: error: unknown argument: '-webso ...

  4. 离PACKET_INp获取信息acket data

         于Floodlight模块假设要packet in消息,就对对应的消息类型进行监听就可以.然后在receive方法中就能够操纵这个上传上来的packet_in.      关键代码:   E ...

  5. [LeetCode116]Path Sum

    题目: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up ...

  6. C#访问Java的WebService添加SOAPHeader验证的问题

    原文:C#访问Java的WebService添加SOAPHeader验证的问题 这两天做与公司OA的接口,发现C#访问Java的WebService需要提供一个SOAP的头验证信息,但是WebServ ...

  7. 国内外MD5在线解密网站

    -http://www.cmd5.com/english.aspx (457,354,352,282) - http://www.md5crack.com - http://www.hashcheck ...

  8. oracle db于,一个特定的数据字典pct miss其计算公式

    这篇文章是原创文章,转载请注明出处: http://blog.csdn.net/msdnchina/article/details/38766801 本文提到的数据字典.以dc_histogram_d ...

  9. OFTP说明

    OFTP (TheOdette File Transfer Protocol,RFC 2204)作为两个商业伙伴中建立EDI连接的一种协议.它由Odette-Organization于1986年创建. ...

  10. VS2015 C#6.0

    VS2015 C#6.0 中的那些新特性 VS2015在自己机器上确实是装好了,(全部安装的话,在Java SE 开发工具包 会卡顿很长时间,我直接关闭,然后重启电脑,重新修复安装搞定), 想来体验一 ...