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
 
 
 
 
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5. int main()
  6. {
  7. int t,n,num,maxn;
  8. int a[];
  9. scanf("%d",&t);
  10. while(t--)
  11. {
  12. scanf("%d",&n);
  13. maxn=-;
  14. memset(a,,sizeof(a));
  15. for(int i=;i<=n;i++)
  16. {
  17. scanf("%d",&num);
  18. a[num]++;
  19. if(a[num]>maxn)
  20. {
  21. maxn=a[num];
  22. }
  23. }
  24. for(int i=;i<=n;i++)
  25. {
  26. if(a[i]==maxn)
  27. {
  28. printf("%d\n",i);
  29. break;
  30. }
  31. }
  32. }
  33. return ;
  34. }

随机推荐

  1. HDU1237 简单的计算器 【堆】+【逆波兰式】

    简单的计算器 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  2. iOS结合导航控制器和标签栏控制器

    <span style="font-family: Arial, Helvetica, sans-serif;"></span><pre name=& ...

  3. MongoDB:逐渐变得无关紧要

    我与MongoDB的关系可分为三个阶段.对于目前处于第三阶段的我来说,这款产品似乎变得无关紧要了.很快你就会明白为什么我这么说. 阶段一:痴迷 我与MongoDB的第一次接触十分神奇:一个poligl ...

  4. thinkphp达到UploadFile.class.php图片上传功能

    片上传在站点里是非经常常使用的功能.ThinkPHP里也有自带的图片上传类(UploadFile.class.php) 和图片模型类(Image.class.php).方便于我们去实现图片上传功能,以 ...

  5. [Java][Android][Process] 分享 Process 运行命令行封装类型

    我在以前的文章中提到,使用Java不会有一个问题,创建运行命令来创建太多进程后创建进程行语句. [Android] ProcessBuilder与Runtime.getRuntime().exec分别 ...

  6. iOS pragma mark要使用

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

  7. Windows Phone 同步方式获取网络类型

    原文:Windows Phone 同步方式获取网络类型 在Windows Phone 开发中有时候需要获取设备当前连接网络的类型,是Wifi,还是2G,3G,或者4G,SDK中提供获取网络类型的API ...

  8. fastjson初始化对性能的影响(转)

    之前在项目中序列化是用thrift,性能一般,而且需要用编译器生成新的类,在序列化和反序列化的时候感觉很繁琐,因此想转到json阵营.对比了jackson,gson等框架之后,决定用fastjson, ...

  9. Tomcat—怎样在Tomcat Webserver下部署Web项目

            总结一下怎样在Tomcat Webserver下部署Web项目:

  10. Java程序猿JavaScript学习笔记(4——关闭/getter/setter)

    计划和完成这个例子中,音符的顺序如下: Java程序猿的JavaScript学习笔记(1--理念) Java程序猿的JavaScript学习笔记(2--属性复制和继承) Java程序猿的JavaScr ...