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. [LeetCode179]Largest Number

    题目: Given a list of non negative integers, arrange them such that they form the largest number. For ...

  2. Alamofire网络库基础教程

    原文 Beginning Alamofire Tutorial 原文作者 Essan Parto译者 星夜暮晨(QQ:412027805) http://www.jianshu.com/p/f1208 ...

  3. 如何更改IE查看源代码菜单使用的HTML编辑器

    一:打开注册表。 二:打开"HKEY_CURRENT_USER/SOFTWARE/MICROSOFT/INTERNET EXPLORER"或"HKEY_LOCAL_MAC ...

  4. Spring.Net控制翻转、依赖注入、面向切面编程

    Spring.Net快速入门:控制翻转.依赖注入.面向切面编程 Spring.Net主要功能: 1.IoC:控制翻转(Inversion of Control)  理解成抽象工厂翻转控制:就是创建对象 ...

  5. js中的json对象

    1.JSON(JavaScript Object  Notation)一种简单的数据格式,比xml更轻巧.JSON是JavaScript原生格式,这意味着在JavaScript中处理JSON数据不须要 ...

  6. C#软件开发实例.个人定制自己的屏幕抓图工具(八)加入了截图功能键盘

    章文件夹 (一)功能概览 (二)创建项目.注冊热键.显示截图主窗体 (三)托盘图标及菜单的实现 (四)基本截图功能实现 (五)针对拖拽时闪烁卡顿现象的优化 (六)加入配置管理功能 (七)加入放大镜的功 ...

  7. 孙陪你,了解它的权力--Kinect结合的发展Unity3D游戏应用开发

    unity3d正在使用kinect三维模型数据控制(它切成脚本) 博主在做项目时须要利用kinect数据控制三维模型中人物的动作.但不是实时控制,而是利用之前获得的骨骼数据,直接控制.无需再利用脚本打 ...

  8. HDU 4819 Mosaic D区段树

    连接:pid=4819">http://acm.hdu.edu.cn/showproblem.php?pid=4819 意:给出一个800×800下面的矩阵.每次更新一个点的值为以这个 ...

  9. 阿里云OSS Multipart Upload上传实例

    原来是用的PutObject()方式上传文件的,但是当文件比较大的时候,总是报一个对方强制关闭连接导致上传失败.PS:公司的网比较渣,10MB的文件都传不上去,搜了下,说使用Multipart Upl ...

  10. javascript滚动栏响应鼠标滑轮的实现上下滚动事件

    实现鼠标滚动滚轮事件: <script type="text/javascript"><pre name="code" class=" ...