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. 【Python项目】配合爱漫画爬取漫画脚本而设计的GUI漫画阅读器 (一)

    博客园的第一个坑,想想都有点小激动 =3= 首先是那个爬虫的地址: [原创]最近写的一个比较hack的小爬虫 选择工具: 以前用过Qt,那么选pyqt4也就是情理之中了. 明确需求: 0.首先,要读取 ...

  2. python udp编程实例

    与python tcp编程控制见 http://blog.csdn.net/aspnet_lyc/article/details/39854569 c++ udp/tcp 编程见 http://blo ...

  3. ORA-12012: error on auto execute of job &quot;ORACLE_OCM

    ALERT日志中报错例如以下: Sun Mar 30 06:05:40 2014 Errors in file /oracle/app/oracle/diag/rdbms/zscims/zscims1 ...

  4. Statement和PreparedStatement的区别; 什么是SQL注入,怎么防止SQL注入? (转)

    问题一:Statement和PreparedStatement的区别 先来说说,什么是java中的Statement:Statement是java执行数据库操作的一个重要方法,用于在已经建立数据库连接 ...

  5. 一个小的日常实践——高速Fibonacci数算法

    上得厅堂.下得厨房.写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练! 题目:高速Fibonacci数算法 内容:先说说Fibonacci数列,它的定义是数列:f1,f2....fn有例如以下规律: ...

  6. Cocos2d-x 如何输出 Android用电话 腰带Tag的Log刊物

    于Cocos2d-x根据代码 #if(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #define LOGAnroid( ...) #else if (CC_TAR ...

  7. TCP/IP 网络精讲:开宗明义及第一课

    内容简介 1.课程大纲 2.第一部分第一课:互联网历史 3.第一部分第二课预告:互联网的创立,OSI七层模型 课程大纲 我们将带大家一起来学习很多网络方面的技能,向大家介绍TCP/IP的基础知识点.你 ...

  8. 虚拟机VM10连衣裙Mac OS X 10.9.3

    最近WWDC终极大招释放--新的编程语言Swift(迅速),导致大波浪,渴望围观程序猿.当然,工欲善其事,其利润,因此,对于那些谁不Mac非常为难.可是,请放心.本文教你怎样在Windows下也能体验 ...

  9. 从Java到C++——从union到VARIANT与CComVariant的深层剖析

    我第一次用VARIANT和CComVariant的时候全然不明确它是怎么回事,为它什么数据类型都能够存放.什么数据都能够被能够初始化?里面究竟是怎么实现的?感觉又奇妙又迷惑!我们在上一节中讲了unio ...

  10. javascript倒置再次被否定作用

    于javascript位反然后可以转换为浮点塑料,而不是更有效parseInt近两倍 var start = new Date().getTime(); for (var i = 0; i < ...