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. NGUI判断是否点击到UI控件

    注意:UI应加上Box Collider 1.射线检测 UICamera发一条射线,射线碰到了东西就说明点击到了UI Ray ray=UICamera.mainCamera.ScreenPointTo ...

  2. Swift学习资料

    http://www.hangge.com/blog/cache/category_72_1.html

  3. Mac OS X Yosemite安装Hadoop 2.6记录

    整个安装过程分为四部分: 一.  安装Homebrew 二.  ssh localhost 三. 安装Hadoop已经进行配置文件设置 (伪分布式) 四. 执行栗子 一. 安装Homebrew 採用H ...

  4. php+sqlite 最佳web服务器

    1 wampserver   支持mysql.每次都启动mysql,可以手动停止.但是运行时有时会很慢. 放弃 2 APS绿色版(Apache+PHP+SQLite)  组件环境:Apache2.2. ...

  5. [精华]Hadoop,HBase分布式集群和solr环境搭建

    1. 机器准备(这里做測试用,目的准备5台CentOS的linux系统) 1.1 准备了2台机器,安装win7系统(64位) 两台windows物理主机: 192.168.131.44 adminis ...

  6. 旧Mj下拉刷新 An instance 0xca90200 of class UITableView was deallocated while key value observers were s

    An instance 0xca90200 of class UITableView was deallocated while key value observers were still regi ...

  7. iOS pragma mark要使用

    郝萌主倾心贡献,尊重作者的劳动成果.请勿转载. 假设文章对您有所帮助.欢迎给作者捐赠.支持郝萌主,捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 简单的来说 ...

  8. 【Shell剧本练习】得出的结论是当前用户

    推断是否当前用户root.假设是暗示root用户,假设而不是提示对于普通用户 #!/bin/bash #title: testus.sh #author: orangleliu #date: 2014 ...

  9. SQLSERVER手动增长日志文件和数据文件

    原文:SQLSERVER手动增长日志文件和数据文件 SQLSERVER手动增长日志文件和数据文件 手动增长日志文件,实际上就是修改日志文件的大小  size 的单位是MB 下面设置日志文件大小是204 ...

  10. 玩转Web之JavaScript(四)-----javaScript语法总结(四) JS中的函数

    1.function/return   function用来定义函数(位于head部分),函数包含着一些代码,这些代码只能被事件激活,或者在函数被调用时才会执行.   return 用来从函数中返回值 ...